Intro To Ooad With Oo Basics
Intro To Ooad With Oo Basics
Intro To Ooad With Oo Basics
For example: An employee object knows how to compute salary. To compute an employee
salary, all that is required is to send the compute payroll message to the employee object.
Different object can respond to the same message in different ways. The car,
motorcycle and bicycle will all respond to a stop message, but the actual operations
performed are object specific.
Class Hierarchy
An object-oriented system organizes classes into a subclass super class hierarchy.
The properties and behaviors are used as the basis for making distinctions between
classes are at the top and more specific are at the bottom of the class hierarchy. The family car
is the subclass of car. A subclass inherits all the properties and methods defined in its super
class.
Inheritance:It is the property of object-oriented systems that allow objects to be built from
other objects. Inheritance allows explicitly taking advantage of the commonality of objects
when constructing new classes. Inheritance is a relationship between classes where one class is
the parent class of another (derived) class. The derived class holds the properties and behavior
of base class in addition to the properties and behavior of derived class.
Dynamic
Inheritance
Dynamic inheritance allows objects to change and evolve over time. Since
base classes provide properties and attributes for objects, hanging base classes changes the
properties and attributes of a class.
Exa
mple
:
A window objects change to icon and back again. When we double click the
folder the contents will be displayed in a window and when close it, changes back to icon. It
involves changing a base class between a windows class and icon class.
Multiple
Inheritances
Some object-oriented systems permit a class to inherit its state (attributes) and behavior
from more than one super class. This kind or inheritance is referred to as multiple inheritances.
For example: Utility vehicle inherits the attributes from the Car and Truck classes.
Polymorphism
Poly ”many” Morph “form”
It means objects that can take on or assume many different forms. Polymorphism
means that the same operations may behave differently on different classes. Booch defines
polymorphism as the relationship of objects many different classes by some common super
class. Polymorphism allows us to write generic, reusable code more easily, because we can
specify general instructions and delegate the implementation detail to the objects involved.
Example: In a pay roll system, manager, office worker and production worker objects all will
respond to the compute payroll message, but the actual operations performed are object
specific.
Ca
n
fly
Pilot Planes
Flow
n by
A pilot “can fly” planes. The inverse of can fly is “is flown by “. Plane “is flown by” pilot
Aggregations: All objects, except the most basic ones, are composed of and may contain other
objects. Breaking down objects in to the objects from which they are composed is de
composition. This is possible because an object attributes need not be simple data fields,
attributes can reference other objects. Since each object has an identity, one object can refer to
other objects. This is known as aggregation. The car object is an aggregation of other
objects such as engine, seat and wheel objects.
Example: a simple example a "dice game" in which software simulates a player rolling two
dice. If the total is seven, they win; otherwise, they lose.
i) Define Use Cases : Requirements analysis may include stories or scenarios of how people
use the application; these can be written as use cases. They are a popular tool in
requirements analysis. For example, the Play a Dice Game use case:
Play a Dice Game: Player requests to roll the dice. System presents results: If the dice
face value totals seven, player wins; otherwise, player loses.
There is an identification of the concepts, attributes, and associations that are considered
important. The result can be expressed in a domain model that shows the important.
domain concepts or objects.
This model illustrates the important concepts Player, Die, and Dice Game, with their
associations and attributes. It is a visualization of the concepts or mental models of a real-
world domain. Thus, it has also been called a conceptual object model.
For example, the sequence diagram in Figure 1.4 illustrates an OO software design, by
sending messages to instances of the DiceGame and Die classes.
Notice that although in the real world a player rolls the dice, in the software design the
DiceGame object "rolls" the dice (that is, sends messages to Die objects). Software object
designs and programs do take some inspiration from real-world domains, but they are not direct
models or simulations of the real world.
iv) Define Design Class Diagrams: a static view of the class definitions is usefully
shown with a design class diagram. This illustrates the attributes and methods of the classes.
For example, in the dice game, an inspection of the sequence diagram leads to the partial
design class diagram shown in Figure 1.5. Since a play message is sent to a DiceGame
object, the DiceGame class requires a play method, while class Die requires a roll and get
FaceValue method.