Ooad Notes
Ooad Notes
NOTES
The object-oriented paradigm took its shape from the initial concept of a
new programming approach, while the interest in design and analysis
methods came much later.
The first object–oriented language was Simula (Simulation of real systems) that
was developed in 1960 by researchers at the Norwegian Computing Center.
In 1970, Alan Kay and his research group at Xerox PARK created a personal
computer named Dynabook and the first pure object-oriented programming
language (OOPL) - Smalltalk, for programming the Dynabook.
In the 1980s, Grady Booch published a paper titled Object Oriented Design that
mainly presented a design for the programming language, Ada. In the ensuing
editions, he extended his ideas to a complete object–oriented design method.
Object-Oriented Analysis
Object–Oriented Analysis (OOA) is the procedure of identifying software
engineering requirements and developing software specifications in
terms of a software system’s object model, which comprises of
interacting objects.
Identifying objects
The common models used in OOA are use cases and object models.
The three analysis techniques that are used in conjunction with each other
for object-oriented analysis are object modelling, dynamic modelling, and
functional modelling.
1. Functional Modelling
Functional Modelling is the final component of object-oriented analysis. The
functional model shows the processes that are performed within an object
and how the data changes as it moves between methods. It specifies the
meaning of the operations of object modelling and the actions of dynamic
modelling. The functional model corresponds to the data flow diagram of
traditional structured analysis.
The process of functional modelling can be visualized in the following steps
−
Rumbaugh et al. have defined DFD as, “A data flow diagram is a graph
which shows the flow of data values from their sources in objects through
processes that transform them to their destinations on other objects.”
Processes,
Data Flows,
Actors, and
Data Stores.
The other parts of a DFD are −
Constraints, and
Control Flows.
Features of a DFD
Processes
Processes are the computational activities that transform data values. A
whole system can be visualized as a high-level process. A process may be
further divided into smaller components. The lowest-level process may be a
simple function.
Data Flows
Data flow represents the flow of data between two processes. It could be
between an actor and a process, or between a data store and a process. A
data flow denotes the value of a data item at some point of the
computation. This value is not changed by the data flow.
In the above figure, Integer_a and Integer_b represent the input data flows
to the process, while L.C.M. and H.C.F. are the output data flows.
Actors
Actors are the active objects that interact with the system by either
producing data and inputting them to the system, or consuming data
produced by the system. In other words, actors serve as the sources and
the sinks of data.
Example − The following figure shows the actors, namely, Customer and
Sales_Clerk in a counter sales system.
Data Stores
Data stores are the passive objects that act as a repository of data. Unlike
actors, they cannot perform any operations. They are used to store data
and retrieve the stored data. They represent a data structure, a disk file, or
a table in a database.
Constraints
Constraints specify the conditions or restrictions that need to be satisfied
over time. They allow adding new rules or modifying existing ones.
Constraints can appear in all the three models of object-oriented analysis.
Example − The following figure shows a portion of DFD for computing the
salary of employees of a company that has decided to give incentives to all
employees of the sales department and increment the salary of all
employees of the HR department. It can be seen that the constraint
{Dept:Sales} causes incentive to be calculated only if the department is
sales and the constraint {Dept:HR} causes increment to be computed only
if the department is HR.
Control Flows
A process may be associated with a certain Boolean value and is evaluated
only if the value is true, though it is not a direct input to the process. These
Boolean values are called the control flows.
The functional model for the Wholesale Software is given below. The figure
below shows the top-level DFD. It shows the software as a single process
and the actors that interact with it.
Customers
Salesperson
Proprietor
In the next level DFD, as shown in the following figure, the major processes
of the system are identified, the data stores are defined and the interaction
of the processes with the actors, and the data stores are established.
Register Customers
Process Sales
Ascertain Gifts
Customer Details
Sales Details
Gift Details
The following figure shows the details of the process Register Customer.
There are three processes in it, Verify Details, Generate C_Code, and
Update Customer Details. When the details of the customer are entered,
they are verified. If the data is correct, C_Code is generated and the data
store Customer Details is updated.
The following figure shows the expansion of the process Ascertain Gifts. It
has two processes in it, Find Total Sales and Decide Type of Gift Coin. The
Find Total Sales process computes the yearly total sales corresponding to
each customer and records the data. Taking this record and the decision of
the proprietor as inputs, the gift coins are allotted through Decide Type of
Gift Coin process.
Levels of DFD
DFD(data flow diagram) can be drawn to represent the system of different
levels of abstraction. Higher level DFDs are partitioned into low levels-
hacking more information and functional elements. Levels in DFD are
numbered 0, 1, 2 or beyond. Here, we will see mainly 3 levels in data flow
diagram, which are: 0-level DFD, 1-level DFD, and 2-level DFD.
0-level DFD:
It is also known as context diagram.It’s designed to be an abstraction view,
showing the system as a single process with its relationship to external
entities. It represent the entire system as single bubble with input and
output data indicated by incoming/outgoing arrows.
1-level DFD:
In 1-level DFD, context diagram is decomposed into multiple
bubbles/processes.in this level we highlight the main functions of the system
and breakdown the high level process of 0-level DFD into subprocesses.
2-level DFD:
2-level DFD goes one step deeper into parts of 1-level DFD.It can be used to
plan or record the specific/necessary detail about the system’s functioning.
1. Object Modelling (static)
Object modelling develops the static structure of the software system in
terms of objects. It identifies the objects, the classes into which the objects
can be grouped into and the relationships between the objects. It also
identifies the main attributes and operations that characterize each class.
Class Diagram helps construct the code for the software application
development.
1. Class Name
2. Attributes
3. Operations
Class Name
Attributes:
An attribute is named property of a class which describes the object
being modeled. In the class diagram, this component is placed just
below the name-compartment.
Relationships
There are mainly three kinds of relationships in UML:
1. Dependencies
2. Generalizations
3. Associations
Dependency
Association:
Multiplicity
Let's say that that there are 100 students in one college. The
college can have multiple students.
Aggregation
Composition:
Dynamic Modelling
After the static behavior of the system is analyzed, its behavior with respect
to time and external changes needs to be examined. This is the purpose of
dynamic modelling.
2.Activity diagrams
3. Usecase diagrams
4. State-machine diagrams
1. Sequence diagrams
Sequence Diagrams –
A sequence diagram simply depicts interaction between objects in a
sequential order i.e. the order in which these interactions take place. We can
also use the terms event diagrams or event scenarios to refer to a sequence
diagram. Sequence diagrams describe how and in what order the objects in
a system function. These diagrams are widely used by businessmen and
software developers to document and understand requirements for new and
existing systems.
We use actors to depict various roles including human users and other
external subjects. We represent an actor in a UML diagram using a stick
person notation. We can have multiple actors in a sequence diagram.
For example – Here the user in seat reservation system is shown as an
actor where it exists outside the system and is not a part of the system.
Figure – an actor interacting with a seat reservation system
Figure – lifeline
We display a lifeline in a rectangle called head with its name and type.
The head is located on top of a vertical dashed line (referred to as the
stem) as shown above. If we want to model an unnamed instance, we
follow the same pattern except now the portion of lifeline’s name is left
blank.
Difference between a lifeline and an actor – A lifeline always
portrays an object internal to the system whereas actors are used to
depict objects external to the system. The following is an example of a
sequence diagram:
Figure – a sequence diagram
Self Message – Certain scenarios might arise where the object needs to
send a message to itself. Such messages are called Self Messages and are
represented with a U shaped arrow.
Reply Message – Reply messages are used to show the message being
sent from the receiver to the sender. We represent a return/reply
message using an open arrowhead with a dotted line. The interaction
moves forward only when a reply message is sent by the receiver.
Figure – reply message
4. Guards – To model conditions we use guards in UML. They are used when we
need to restrict the flow of messages on the pretext of a condition being met.
Guards play an important role in letting software developers know the
constraints attached to a system or a particular process.
For example: In order to be able to withdraw cash, having a balance
greater than zero is a condition that must be met as shown below.
The above sequence diagram depicts the sequence diagram for an emotion
based music player:
1. Firstly the application is opened by the user.
2. The device then gets access to the web cam.
3. The webcam captures the image of the user.
4. The device uses algorithms to detect the face and predict the mood.
5. It then requests database for dictionary of possible moods.
6. The mood is retrieved from the database.
7. The mood is displayed to the user.
8. The music is requested from the database.
9. The playlist is generated and finally shown to the user.
2. Collaboration diagrams
Unlike a sequence diagram, a collaboration diagram shows the relationships
among the objects. Sequence diagrams and collaboration diagrams express
similar information, but show it in different ways.
Because of the format of the collaboration diagram, they tend to better
suited for analysis activities (see Activity: Use-Case
Analysis). Specifically, they tend to be better suited to depicting simpler
interactions of smaller numbers of objects. However, if the number of
objects and messages grows, the diagram becomes increasingly hard to
read. In addition, it is difficult to show additional descriptive information
such as timing, decision points, or other unstructured information that can
be easily added to the notes in a sequence diagram. So, here are some use
cases that we want to create a collaboration diagram for:
Model collaborations between objects or roles that deliver the functionalities
Capture interactions that show the messages passing between objects and
Model alternative scenarios within use cases or operations that involve the
cases
The top-level message is numbered 1. Messages sent during the same call
have the same decimal prefix but suffixes of 1, 2, etc. according to when
they occur.
Notations of Collaboration Diagram
Objects
The objects can be unnamed, but you should name them if you want to
Actors
Links
Links connect objects and actors and are instances of associations and each
link corresponds to an association in the class diagram
Links are defined as follows:
A link is a relationship among objects across which messages can be sent.
objects.
An object interacts with, or navigates to, other objects through its links to
these objects.
A link can be an instance of an association, or it can be anonymous,
Messages
and operation
diagrams
Action Flow
Action flows, also called edges and paths, illustrate the transitions
from one action state to another. They are usually drawn with an
arrowed line.
Object Flow
Object flow refers to the creation and modification of objects by
activities. An object flow arrow from an action to an object means that
the action creates or influences the object. An object flow arrow from
an object to an action indicates that the action state uses the object.
Guards
In UML, guards are a statement written next to a decision diamond
that must be true before moving next to the next activity. These are
not essential, but are useful when a specific answer, such as "Yes,
three labels are printed," is needed before moving forward.
Synchronization
A fork node is used to split a single incoming flow into multiple
concurrent flows. It is represented as a straight, slightly thicker line in
an activity diagram.
A join node joins multiple concurrent flows back into a single outgoing
flow.
A fork and join mode used together are often referred to as
synchronization.
Time Event
This refers to an event that stops the flow for a time; an hourglass
depicts it.
Merge Event
A merge event brings together multiple flows that are not concurrent.
Interrupting Edge
An event, such as a cancellation, that interrupts the flow denoted with
a lightning bolt.
Swimlanes
Swimlanes group related activities into one column.
Example:
Usecase diagrams
A use case diagram is a dynamic or behavior diagram in UML. Use case
diagrams model the functionality of a system using actors and use cases.
Use cases are a set of actions, services, and functions that the system needs
to perform. In this context, a "system" is something being developed or
operated, such as a web site. The "actors" are people or entities operating
under defined roles within the system.
Use case diagrams are valuable for visualizing the functional requirements of
a system that will translate into design choices and development priorities.
They also help identify any internal or external factors that may influence
the system and should be taken into consideration.
They provide a good high level analysis from outside the system. Use case
diagrams specify how the system interacts with actors without worrying
about the details of how that functionality is implemented.
Use Case
Draw use cases using ovals. Label the ovals with verbs that represent the
system's functions.
Actors
Actors are the users of a system. When one system is the actor of another
system, label the actor system with the actor stereotype.
Relationships
Illustrate relationships between an actor and a use case with a simple line.
For relationships among use cases, use arrows labeled either "uses" or
"extends." A "uses" relationship indicates that one use case is needed by
another in order to perform a task. An "extends" relationship indicates
alternative options under a certain use case.
Example:
State machine diagrams
tate machine diagram typically are used to describe state-dependent
behavior for an object. An object responds differently to the same
event depending on what state it is in. State machine diagrams are
usually applied to objects but can be applied to any element that has
behavior to other entities such as: actors, use cases, methods, subsystems
systems and etc. and they are typically used in conjunction with interaction
diagrams (usually sequence diagrams).
For example:
Consider you have $100,000 in a bank account. The behavior of the
withdraw function would be: balance := balance - withdrawAmount;
provided that the balance after the withdrawal is not less than $0; this
is true regardless of how many times you have withdrawn money from the
bank. In such situations, the withdrawals do not affect the abstraction of the
attribute values, and hence the gross behavior of the object remains
unchanged.
However, if the account balance would become negative after a
withdrawal, the behavior of the withdraw function would be quite different.
This is because the state of the bank account is changed from positive to
negative; in technical jargon, a transition from the positive state to the
negative state is fired.
The abstraction of the attribute value is a property of the system, rather
than a globally applicable rule. For example, if the bank changes the
business rule to allow the bank balance to be overdrawn by 2000 dollars, the
state of the bank account will be redefined with condition that the balance
after withdrawal must not be less than $2000 in deficit.
Note That:
A state machine diagram describes all events (and states and transitions for
a single object)
A sequence diagram describes the events for a single interaction across all
objects involved
Basic Concepts of State Machine Diagram
What is a State?
State Notation
State
Example:
Events
Transition
Transition lines depict the movement from one state to another. Each
transition line is labeled with the event that causes the transition.
Viewing a system as a set of states and transitions between states is very
useful for describing complex behaviors
Understanding state transitions is part of system analysis and design
A Transition is the movement from one state to another state
Transitions between states occur as follows:
1. An element is in a source state
2. An event occurs
3. An action is performed
4. The element enters a target state
Multiple transitions occur either when different events result in a state
terminating or when there are guard conditions on the transitions
A transition without an event and action is known as automatic transitions
Actions
Activity
Entry and Exit actions specified in the state. It must be true for every entry /
exit occurrence. If not, then you must use actions on the individual
transition arcs
Entry Action executed on entry into state with the notation: Entry /
action
Exit Action executed on exit from state with the notation: Exit / action
Example - Entry / Exit Action (Check Book Status)
Implementation of associations.
After the analysis phase, the conceptual model is developed further into an
object-oriented model using object-oriented design (OOD). In OOD, the
technology-independent concepts in the analysis model are mapped
onto implementing classes, constraints are identified, and
interfaces are designed, resulting in a model for the solution
domain. In a nutshell, a detailed description is constructed
specifying how the system is to be built on concrete technologies
System Design
Object-oriented system design involves defining the context of a system
followed by designing the architecture of the system.
Context − The context of a system has a static and a dynamic part. The static
context of the system is designed using a simple block diagram of the whole
system which is expanded into a hierarchy of subsystems. The subsystem
model is represented by UML packages. The dynamic context describes how the
system interacts with its environment. It is modelled using use case
diagrams.
Object-Oriented Programming
Object-oriented programming (OOP) is a programming paradigm based
upon objects (having both data and methods) that aims to incorporate the
advantages of modularity and reusability. Objects, which are usually
instances of classes, are used to interact with one another to design
applications and computer programs.