Professional Documents
Culture Documents
Alamirew Gedif
Learning Objectives
At the completion of this chapter, you are able to understand
– The Object-Oriented philosophy and why we need to study it
– The Unified Approach
– Objects and Classes, and their differences
– Class Attributes and Methods
– The concept of Messages
– Class hierarchy inheritance and multiple inheritance
– Encapsulation and Information hiding
– Polymorphism
– Advantages of OO approach
– Aggregation and composition
20
Overview of The Unified Approach …cont’d
The User Interface (View) Layer
• The user interface layer consists of objects with which the user
interacts as well as the objects needed to manage or control the
interface.
• The user interface layer also is called the view layer.
• This layer typically is responsible for two major aspects of the
applications:
– Responding to user interaction. The user interface layer objects
must be designed to translate actions by the user, such as
clicking on a button or selecting from a menu, into an
appropriate response
– Displaying business objects. This layer must paint the best
possible picture of the business objects for the user.
35
Principles of Object-Oriented Systems…cont’d
An inheritance relationship can be identified:
“IS–A” Or “A-KIND-OF”inheritance: It defines the hierarchical relationship in
inheritance, whereby from a super-class, a number of subclasses may be derived
which may again have subclasses and so on. Ex., if we derive a class Rose from a
class Flower, we can say that a rose is a flower.
“PART–OF” inheritance: It defines the hierarchical relationship in aggregation by
which a class may be composed of other classes. Ex., a flower is composed of
sepals, petals, stamens, and carpel. It can be said that a petal is a part of flower.
38
Principles of Object-Oriented Systems…cont’d
Dynamic Inheritance
• Dynamic inheritance allows objects to change and evolve over time.
Since base classes provide properties and attributes for objects,
changing base classes changes the properties and attributes of a class.
A Windows object can be changed into an Icon and then back again,
which involves changing a base class between a Windows class and an
Icon class.
• Dynamic inheritance refers to the ability to add, delete, or change
parents from objects (or classes) at run time.
• In object-oriented programming languages, variables can be declared
to hold or reference objects of a particular class.
– For example, a variable declared to reference a motor vehicle is
capable of referencing a car or a truck or any subclass of motor
vehicle.
39
Principles of Object-Oriented Systems…cont’d
Polymorphism
• Poly means “many” and morph means “form”, and Polymorphism means
that the same message or operation can be interpreted differently by
different classes of objects.
• Polymorphic operations are used in the context of an inheritance
hierarchy where the same operation may be implemented differently in
each subclass. A single message will produce a different response
depending on the class of the object to which it is sent.
• Different pieces of information need to be collected and stored. We do
not have to be concerned with how something is done when using
objects. We can simply send a message to an object, and that object will
be responsible for interpreting the message appropriately.
• For example, if we sent the message “Draw yourself ” to a square object, a
circle object, and a triangle object, the results would be very different,
even though the message is the same.