ObjectOriented Programming Concepts - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

ObjectOriented Programming Concepts

Description:

Software objects model read-world objects or abstract concepts. dog, bicycle, queue ... Any parameters needed by the method (low gear) The Benefits of Messages ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 15
Provided by: ccNct
Category:

less

Transcript and Presenter's Notes

Title: ObjectOriented Programming Concepts


1
Object-Oriented Programming Concepts
2
????
  • What are Objects?
  • What are Classes?
  • What are Messages?
  • What is Inheritance?

3
What Are Objects?
  • Software objects model read-world objects or
    abstract concepts
  • dog, bicycle, queue
  • Real-world objects have states and behaviors
  • Dogs' states name, color, breed, hungry
  • Dogs' behaviors barking fetching
  • How do Software objects implement real-world
    objects?
  • Use variables to implement states
  • Use methods to implement behaviors
  • An object is a software bundle of variables and
    related methods

4
Visual Representation of A Software Object
Variable
Method
5
Software Bicycle
  • Instance Variables and Instance Method

6
Encapsulation
  • The objects' variables make up the center of the
    object.
  • Methods surround and hide the object's center
    from other objects.
  • Benefit of encapsulation
  • Modularity
  • Information hiding
  • For implementation or efficiency reasons, an
    object may wish to expose some of its variables
    or hide some of its methods.

7
What Are Classes?
  • A class is a blueprint or prototype defining the
    variables and methods common to all objects of a
    certain kind.
  • An object is an instance of a certain class.
  • After you have created a class, you must create
    an instance of it before you can use.
  • Class variables and class methods
  • The benefit of Classes Reusability

8
Visual Representation of A Software Class
9
What Are Messages?
  • Software objects interact and communicate with
    each other by sending messages to each other.

10
More on Messages
  • Components of a Message
  • The object to whom the message is addressed (Your
    Bicycle)
  • The name of the method to perform(changeGears)
  • Any parameters needed by the method (low gear)
  • The Benefits of Messages
  • Messages passing supports all possible
    interactions between objects (aside from direct
    variable access)
  • Objects dont need to be in the same process or
    even on the same machine to send and receive
    messages.

11
What is Inheritance?
  • Inheritance allows classes to be defined in terms
    of other classes
  • superclass and subclass
  • Each subclass inherits variables and methods from
    its superclass.
  • Subclasses can add variables and methods to the
    ones they inherit from the superclass.
  • Subclasses can also override inherited method and
    provide specialized implementations for those
    methods.
  • Inheritance or class hierarchy

12
Benefits of Inheritance
  • Programmers can reuse the code in the superclass
    many times.
  • Programmers can implement superclasses called
    abstract classes
  • Abstract class defines generic behaviors
  • Define and may partially implement the behavior
    but much of the class is undefined and
    unimplemented. Other programmers fill in the
    details with specialized subclasses.

13
Message Example
14
Inheritance Example
Write a Comment
User Comments (0)
About PowerShow.com