Intro To Ooad With Oo Basics

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

INTRODUCTION TO OOAD WITH OO BASICS


Object Oriented analysis and design skills are essential for the creation of well- designed,
robust, and maintainable software using OO technologies and languages such as Java or C#.
Requirements analysis and OOA/D needs to be presented and practiced in the context of
some development process. In this case, an agile (light, flexible) approach to the well- known
Unified Process (UP) is used as the sample iterative development process are taken . It
includes

Apply principles and patterns to create better object designs.


Iteratively follow a set of common activities in analysis and design, based on an agile
approach to the UP as an example.
Create frequently used diagrams in the UML notation.

What is Analysis and Design?


Analysis (do the right thing ) emphasizes an investigation of the problem and
requirements, rather than a solution. For example, if a new online trading system is desired,
how will it be used? What are its functions?
Design (do the thing right ) emphasizes a conceptual solution (in software and
hardware) that fulfills the requirements, rather than its implementation. For example, a
description of a database schema and software objects. Design ideas often exclude low-level or
"obvious" detail.
OO Basics
Object: A car is an object a real-world entity, identifiably separate from its surroundings. A
car has a well-defined set of attributes in relation to other object.

Attributes: Data of an object. ,Properties of an object.

Methods: Procedures of an object. or Behavior of an object.


The term object was for formal utilized in the similar language. The term object means a
combination or data and logic that represent some real-world entity.
When developing an object oriented applications, two basic questions arise,
1. What objects does the application need?
2. What functionality should those objects have?
Programming in an object-oriented system consists of adding new kind of objects to
the system and defining how they behave. The new object classes can be built from the
objects supplied by the object-oriented system.

Object state and properties (Attributes)

Properties represent the state of an object. In an object oriented methods we want


to refer to the description of these properties rather than how they are represented in a particular
programming language.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

We could represent each property in several ways in a programming


For example: Color
1. Can be declared as character to store sequence or character [ex: red, blue, ..]
2. Can declared as number to store the stock number of paint [ex: red paint, blue
pain
t, ..]
3. Can be declared as image (or) video file to refer a full color video image.

The importance of this distinction is that an object abstract state can be


independent of its physical representation.

Object Behavior and Methods:


We can describe the set of things that an object can do on its own (or) we
can do with it. For example: Consider an object car, We can drive the car. We can
stop the car.
Each of the above statements is a description of the objects behavior. The

jects behavior is described in methods or procedures. A method is a function or


procedures that is defined in a class and typically can access to perform some operation.
Behavior denotes the collection of methods that abstractly describes what an object is
capable of doing. The object which operates on the method is called receiver. Methods
encapsulate the behavior or the object, provide interface to the object and hide any of the internal
structures and states maintained by the object. The procedures provide us the means to
communicate with an object and access it properties.

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.

Objects Respond to Messages: The capability of an object’s is determined by the methods


defined for it. To do an operation, a message is sent to an object. Objects represented to
messages according to the methods defined in its class.
For example:
When we press on the brake pedal of a car, we send a stop message to the car
object. The car object knows how to respond to the stop message since brake have been designed
with specialized parts such as brake pads and drums precisely respond to that message.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

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.

It is the receiver’s responsibility to respond to a message in an appropriate


manner. This gives the great deal or flexibility, since different object can respond to the
same message in different ways. This is known as polymorphism.

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.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

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.

Encapsulation and Information Hiding


Information hiding is the principle of concealing the internal data and

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

procedures of an object. In C++ , encapsulation protection mechanism with private, public


and protected members.
A car engine is an example of encapsulation. Although engines may differ in
implementation, the interface between the driver and car is through a common protocol.

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.

Object Relationship and Associations


Association represents the relationships between objects and classes. Associations are bi-
directional. The directions implied by the name are the forward direction and the opposite is
the inverse direction.

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.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

Static and Dynamic Binding:


Determining which function has to be involved at compile time is called static
binding. Static binding optimized the calls. (Ex) function call.
The process of determining at run time which functions to involve is termed
dynamic binding. Dynamic binding occurs when polymorphic call is issued. It allows some
method invocation decision to be deferred until the information is known.
Object Persistence:
Objects have a lifetime. They are explicitly created and can exist for a period of
time that has been the duration of the process in which they were created. A file or database can
provide support for objects having a longer lifeline, longer than the duration of the process for
which they are created. This characteristic is called object persistence.

What is Object-Oriented Analysis and Design?

Object-Oriented Analysis : It emphasis on finding and describing the objects or


concepts in the problem domain. For example, in the case of the flight information system,
some of the concepts include Plane, Flight, and Pilot.
Object-Oriented Design : It emphasis on defining software objects and how they
collaborate to fulfill the requirements. For example, a Plane software object may have a tail
Number attribute and a get FlightHistory method.
During implementation or object-oriented programming, design objects are
implemented, such as a Plane class in Java.
Object-orientation emphasizes representation of objects.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

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.

ii) Define a Domain Model

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.

Partial domain model of the dice game.

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.

iii) Assign Object Responsibilities and Draw Interaction Diagrams

Object-oriented design is concerned with defining software objects their responsibilities


and collaborations. It shows the flow of messages between software objects, and thus the
invocation of methods.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN


ROHINI COLLEGE OF ENGINEERING AND TECHNOLOGY

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.

Sequence diagram illustrating messages between software objects.

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.

Partial design class


diagram.

CS 8592 OBJECT ORIENTED ANALYSIS AND DESIGN

You might also like