Top Banner
Copyright ©2005 Department of Computer & Information Science Object Oriented Concepts
14

12429_basics of Oops

Jun 03, 2018

Download

Documents

Khushbu Thakur
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 1/14

Copyright ©2005 Department of Computer & Information Science

Object Oriented Concepts

Page 2: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 2/14

 

Copyright ©2005 Department of Computer & Information Science

Goals

• Understand objects, their attributesand their methods.

• Understand the pillars of object-oriented programming asencapsulation, inheritance &

polymorphism.

Page 3: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 3/14

 

Copyright ©2005 Department of Computer & Information Science

OOP Concepts

• Objects

• Attributes

• Methods• Events

• Abstraction & Classes• Constructors

Page 4: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 4/14

 

Copyright ©2005 Department of Computer & Information Science

What is an object?

• An object is a unique programmingentity that has attributes to describe

it (like adjectives in grammar) andmethods to retrieve/set attributevalues (like verbs in grammar).

Page 5: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 5/14

 

Copyright ©2005 Department of Computer & Information Science

 Attributes

• Programmers store an object’s data inattributes, also called properties.

• Attributes provide us a way todescribe an object, similar toadjectives in grammar.

• We can read property values orchange properties, assigning values.

Page 6: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 6/14

 

Copyright ©2005 Department of Computer & Information Science

Methods

• Whereas attributes describe anobject, methods allow us to access

object data. Methods are like verbs ingrammar.

• We can manipulate object data,

stored in attributes, using methods.

Page 7: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 7/14

 

Copyright ©2005 Department of Computer & Information Science

Events

• Object-oriented programming isinherently tied to user interaction.

Programs record interaction in theform of events.

• Events are changes in an object’s

environment to which it can react.

Page 8: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 8/14

 

Copyright ©2005 Department of Computer & Information Science

 Abstraction

• One of the chief advantages ofobject-oriented programming is the

idea that programmers can essentiallyfocus on the “big picture” and ignorespecific details regarding the inner-

workings of an object. This concept iscalled abstraction .

Page 9: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 9/14

 

Copyright ©2005 Department of Computer & Information Science

Classes

• How do programmers get byimplementing abstraction? They use a

programming structure called a class .• A class presents a blueprint of an

object, its properties and its methods.

Page 10: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 10/14

 

Copyright ©2005 Department of Computer & Information Science

Instantiation

• To create an object based on a class,we create an instance of that class.

This process is called instantiation.• In Java, JavaScript and other

languages, we use a special method

called a constructor method  to createan instance of an object.

Page 11: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 11/14

 

Copyright ©2005 Department of Computer & Information Science

Encapsulation

• Abstraction in OOP is closely relatedto a concept called encapsulation .

• Data and the ways to get at that dataare wrapped in a single package, aclass. The only way to access such

data is through that package. Thisidea translates to information hiding.

Page 12: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 12/14

 

Copyright ©2005 Department of Computer & Information Science

Inheritance

• Another of the main tenets of OOP isinheritance . Inheritance allows

programmers to create new classesfrom existing ones.

• A child class inherits its properties

and attributes from its parents, whichprogrammers can change.

Page 13: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 13/14

 

Copyright ©2005 Department of Computer & Information Science

Polymorphism

• Polymorphism describes howprogrammers write methods to do

some general purpose function.• Different objects might perform

polymorphic methods differently.

Page 14: 12429_basics of Oops

8/11/2019 12429_basics of Oops

http://slidepdf.com/reader/full/12429basics-of-oops 14/14

 

Copyright ©2005 Department of Computer & Information Science

Summary

• Programming objects are comprisedof attributes and methods.

• Classes provide programmers withblueprints of objects.

• To create an object from a class, weuse constructor methods to create aclass instance.