1 / 12

Agenda

Learn about the principles of encapsulation and information hiding in object-oriented programming, class hierarchy, inheritance, polymorphism, associations, and aggregations.

jorgensena
Download Presentation

Agenda

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object basics (continued) Encapsulation & Information Hiding Class Hierarchy Inheritance Polymorphism Associations Aggregations Object Oriented Analysis and Design Agenda

  2. An object is said to encapsulate the data & a program No object can operate directly on another object’s data Object’s internal format is insulated from other object’s Permissible operations Data Private Protocol Massages Public Protocol Object basics: Encapsulation & Information Hiding:

  3. Very general encapsulation mechanisms are private, public & protected Public members may be accessed from anywhere Private members are accessible only from within a class Protected members can be accessed only from subclasses Object basics: Encapsulation & Information Hiding: Encapsulation & Information Hiding:

  4. An important factor in achieving encapsulation is the design of different classes of objects that operate using common protocol Protocol is an interface to the object TV contains many complex components, but you do not need to know about them to use it Data abstraction is a benefit of the object oriented concepts that incorporates encapsulation & polymorphism Object basics: Encapsulation & Information Hiding:

  5. Object basics: Class Hierarchy: • An object oriented system organize classes into a super class – subclass hierarchy • Different properties and behaviors are used as the basis for making distinction between super & subclasses • A subclass inherits all of the properties & methods defined in a super class • Eliminates duplication by allowing classes to share & reuse behaviors

  6. Object basics: Inheritance: • A relationship between classes where one class is the parent of another class • It allows classes to share & reuse behavior & attributes • We can “build on what we already have” & “reuse what we already have”

  7. Object basics: Multiple Inheritance: • OO systems permit a class to inherit from more than one superclass • This kind of inheritance is referred to as multiple inheritance • For example utility vehicle inherits from Car and Truck classes

  8. Object basics: • Poly means “many” & morph means “form” • Same operation may behave differently on different objects • Draw message can be sent to many objects like triangle, circle or line & each object could act differently • Polymorphism is the main difference between a message and a subroutine call • It allows us write generic, reusable code more easily, because we can specify general instructions & delegate the implementation details to the object involved Polymorphism:

  9. Object basics: Associations: • Represents relationship between objects • For example a pilot can fly planes. • Associations are Bidirectional • An important issue in association is cardinality

  10. Request for printing PrintServer Item Object basics: Associations: Client server association: • A special form of association is a client-server relationship. • This relationship can be viewed as one-way interaction: one object (client) requests the service of another object (server).

  11. Book Publication Author Category Object basics: Aggregations: • Aggregation is a form of association • Objects are composed of & may contain other objects • One object’s attributes can reference to other objects, where an attribute can be object itself • Example

  12. Object basics: Aggregations: • Example

More Related