Object Oriented Analysis and Design Agenda Object basics
Object Oriented Analysis and Design Agenda • Object basics (continued) – Encapsulation & Information Hiding – Class Hierarchy – Inheritance – Polymorphism – Associations – Aggregations
Object basics: Encapsulation & Information Hiding: Ø An object is said to encapsulate the data & a program Permissible operations Data Private Protocol Public Protocol Massages Ø No object can operate directly on another object’s data Ø Object’s internal format is insulated from other object’s
Object basics: Encapsulation & Information Hiding: Ø 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: Ø 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: 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
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”
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
Object basics: Polymorphism: Ø 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
Object basics: Associations: Ø Represents relationship between objects Ø For example a pilot can fly planes. Ø Associations are Bidirectional Ø An important issue in association is cardinality
Object basics: Associations: Client server association: ØA special form of association is a clientserver relationship. ØThis relationship can be viewed as one-way interaction: one object (client) requests the service of another object (server). Print. Server Request for printing Item
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 Book Publication Author Category
Object basics: Aggregations: Ø Example
- Slides: 12