Professional Documents
Culture Documents
On
Software Engineering
Chapter-7
Software Design: Object Oriented Design using
UML
Prepared By:
Kunal Anand, Asst. Professor
SoCE, KIIT, DU, Bhubaneswar-24
Organization of the Chapter
27 October 2022 2
Introduction to Object Oriented Design
• Object Oriented Design (OOD) is another popular design
approach followed in software development process.
27 October 2022 3
Overview of Object-Oriented Concepts
• In object-oriented concepts, following key concepts are used:
– Object
– Class
– Message and methods
– Abstraction
– Encapsulation
– Inheritance
– Polymorphism
– Message binding
– Genericity
27 October 2022 4
Object Oriented Concepts (contd..)
• Object:
– Any real-world entity can be considered as an object.
– An object can access only its own data using its methods.
However, it can interact with other objects in order to
perform some task.
• Composite Objects:
– Objects that contain other objects are called composite
objects. They can be used to realize complex behavior.
27 October 2022 10
Related terms
• Persistent objects:
– The permanently stored objects are known as persistent objects.
They live across different execution.
– It can be done by keeping a copy of object in secondary storage.
• Agents:
– They are known as active objects.
– They monitor events occurring in the application and act
autonomously.
– They are used in applications like monitoring exceptions.
• Widget:
– Widget stands for “window object”. It is a primitive object used in
UML.
– It maintains internal data. The methods supported by a widget
manipulate the stored data and carry out operations.
27 October 2022 11
Advantages of OOD
• Code and design reuse
• Increased productivity
• Ease of testing and maintenance
• Better understandability
• Cost effective
– A functioning and well-established object-oriented
methodology and environment is likely to be managed with
20-50% of the cost of the traditional development.
27 October 2022 12
Unified Modeling Language
• Unified Modeling Language, UML, provides a set of notations
to create models of a system.
27 October 2022 13
UML Diagrams
• UML diagrams can capture following five views of a system:
– User's view:
• This view defines the functionalities made available by
the system to its users.
• It captures the external view of a system i.e., how a user
sees the system from outside.
• The user's view is considered as “black box” view
where the users don’t have any idea about “how the
system is working”. They can only use the system
without knowing its internal structure.
• The diagram under user's view is known as use case
diagram.
27 October 2022 14
UML Diagrams (contd..)
• Structural View:
– It defines the objects that are important to the
understanding of the working of a system, and its
implementation.
– It also captures the relationship among the objects.
– Diagrams: object diagram, class diagram
• Behavioral View:
– It captures the interactions among the objects to realize the
overall system behavior.
– Diagrams: sequence diagram, activity diagram, state-chart
diagram, collaboration diagram
27 October 2022 15
UML Diagrams (contd..)
• Implementation view:
– This view captures the important components and their
dependencies.
– Diagram: Component diagram
• Environmental view:
– This view models how the different components of the
system are implemented on a different piece of hardware.
– Diagram: Deployment diagram
27 October 2022 16
Use Case Diagram
• In UML, a use case diagram can summarize the details of the
system's users (also known as actors).
• Use case diagrams are ideal for:
– Representing the goals of system-user interactions
– Defining and organizing functional requirements in a
system
– Specifying the context and requirements of a system
– Modeling the basic flow of events in a use case
• An effective use case diagram can help your team discuss and
represent scenarios in which the system or application interacts
with people, organizations, or external systems
27 October 2022 17
Use Case Diagram (contd..)
• A use case diagram, usually have following components:
– Actors: Stick figures that represent the people employing
the use cases.
27 October 2022 20
Generalization
• In generalization relationship, the behavior of the ancestor is
inherited by the descendant.
• This is used when there is common behavior between two use
cases and specialized behavior specific to each use case.
• For example, there might be a generalized use case called
“Pay Bills”. This can be extended to specific use cases like
“Pay by Card”, “Pay by Net banking”, “Pay by UPI” etc.
27 October 2022 21
Include Relationship
• Include relationship shows that the behavior of the included
use case, is part of the including (base) use case.
• The main reason for this is, to reuse the common actions
across multiple use cases. In some situations, this is done to
simplify complex behaviors. Few things to consider when
using the <<include>> relationship.
• The base use case is incomplete without the included use case.
The included use case is mandatory and not optional.
27 October 2022 22
Extend Relationship
• The extend relationship allows to show the optional system
behavior.
• Extend relationship is shown as a dashed line with an open
arrowhead directed from the extending use case to the
extended (base) use case. The arrow is labeled with the
keyword «extend».
• The extend use case can add additional behavior only at an
extension point when certain conditions are satisfied.
• Registration use case is complete and meaningful on its own. It
could be extended with optional “Get Help On Registration”
use case.
27 October 2022 23
Use Case Diagram (contd..)
• Problem Title: ATM Application: In general, the interaction
between a user and bank ATM machine happens as below:
– A user logs into the system. This login is authenticated by the
bank administration. The login may result in either successful
login or FAILED login. In case of successful login, the user is
navigated to the TRANSACTION option. However, The user
gets the INCORRECT PIN message and prompted to enter the
correct PIN, in case of FAILED login.
– User is offered with different options available under
TRANSACTION. These options include BALANCE CHECK,
WITHDRAWL, DEPOSIT, FUNDS TRANSFER and other
services. All these options can be performed by the user but only
one at a time. The bank administration authenticates these
transactions option.
– The ATM system is maintained by an IT team which mainly
includes SYSTEM MAINTENANCE and REPORT
27 October 2022
GENERATION work. 24
Solution
• Actors: USER, BANK and IT Team
• Relationships:
– Actors USER and BANK is associated to LOGIN
– BANK is also associated to Transaction.
– Transaction includes BALANCE CHECK, WITHDRAWL,
DEPOSIT, FUNDS TRANSFER and other services.
– Actor IT team is associated to Maintenance which includes
SYSTEM MAINTENANCE (SM) and REPORT
GENERATION (RG).
27 October 2022 25
Use Case Diagram for ATM Application
27 October 2022 26
Class Diagram
• Class diagram is a graphical representation of the static view
of the system and represents different aspects of the
application.
27 October 2022 27
Class Diagram
• The following points should be remembered while drawing a
class diagram:
– The name of the class diagram should be meaningful to
describe the aspect of the system.
– Each element and their relationships should be identified in
advance.
– Responsibility (attributes and methods) of each class
should be clearly identified
– For each class, minimum number of properties should be
specified, as unnecessary properties will make the diagram
complicated.
– Use “notes” whenever required to describe some aspect of
the diagram. At the end of the drawing, it should be
understandable to the developer/coder.
27 October 2022 28
An Example: Loan_Account
• In the example, a class called “loan_account” is depicted.
Classes in class diagrams are represented by boxes that are
partitioned into three:
– The top partition contains the name of the class.
– The middle part contains the class’s attributes.
– The bottom partition shows the possible operations that are
associated with the class.
27 October 2022 29
Relationship in Class Diagram
• In a class diagrams, the classes are interrelated to each other in
following relationships:
– Association: Any logical connection between two classes.
27 October 2022 30
contd..
• Aggregation:
– Aggregation is a special type of association where the
involved classes support “whole-part” relationship
between them.
– It is a weak type of association.
– Here, the contained class is not strongly dependent on the
container class.
– Aggregation is represented by an empty diamond symbol at
the aggregate end of a relationship.
27 October 2022 31
contd..
• Composition:
– It is also a whole/part relationship. It is a stricter form of aggregation,
in which the “part” is existence dependent on “whole”.
– In composition, there is a strong relationship between the container
and contained classes. The contained class will lose its significance if
the container class is deleted.
– Composition relationship is denoted using a straight line with a filled
diamond drawn at the composite end.
• Aggregation vs Composition:
– If components can be added to or removed from the aggregate, then
the relationship is aggregation. On the other hand, if the
components are not required to be added/deleted dynamically, then
the relationship is composition.
27 October 2022 32
contd..
• Inheritance:
– It refers to a type of
relationship wherein one
associated class is a child of
another by virtue of assuming
the same functionalities of
the parent class.
– In other words, the child class
is a specific type of the parent
class.
– To show inheritance in a
UML diagram, a solid line
from the child class to the
parent class is drawn using an
unfilled arrowhead.
27 October 2022 33
Class Diagram for ATM Application
• Problem Description: An ATM application can be described as below:
– A Bank, with a branch code and location, maintains and manages
various customers and ATMs.
– A Customer has to provide basic personal information like name, date
of birth and address to their bank. The customers can have one or more
accounts in the bank. The bank issues debit card to each of its
customers. A customer can perform one or many transaction using the
debit card by visiting the bank ATM.
– An Account can be either Savings or PPF account with the details like
account number, account balance and it supports two functions named
as deposit and withdraw. Additionally, PPF account also has a maturity
date.
– The ATMs are assigned with unique ID and are situated at different
locations. The ATM is managed by the bank. ATM identifies
customers and performs the transactions opted by them.
– Every Transaction has unique transaction ID, date of transaction, type
of transaction, amount and balance after transaction. The ATM
transaction updates the customer account after successful completion of
27 October 2022 34
the transaction.
contd..
27 October 2022 35
Object Diagram
• A class diagram represents an abstract model consisting of
classes and their relationship.
• An object diagram shows a snapshot/instance of the objects in
a system at a point in time. It is also known as instance
diagram.
• It captures the static view of a system at a particular moment.
• The purpose of the object diagram can be summarized as:
– Forward and reverse engineering.
– Object relationships of a system
– Static view of an interaction.
– Understand object behavior and their relationship from
practical perspective
27 October 2022 36
Notations used in Object Diagram
• Object Notation:
– The object we create represents an entity which exists in the system.
– We can represent the changes in object over time by creating
multiple instance specifications.
– We use a rectangle to represent an object in an Object Diagram. An
object is generally linked to other objects in an object diagram.
27 October 2022 37
contd..
• Links – We use a link to represent a relationship between two
objects.
• Association
• Aggregation
• Composition
27 October 2022 38
Object Diagram
• To capture a particular system, numbers of class diagrams are
limited. However, if we consider object diagrams then we can
have unlimited number of instances, which are unique in
nature. Only those instances are considered, which have an
impact on the system.
• From the above discussion, it is clear that a single object
diagram cannot capture all the necessary instances or rather
cannot specify all the objects of a system. Hence, the solution
is:
– First, analyze the system and decide which instances have
important data and association.
– Second, consider only those instances, which will cover the
functionality.
– Third, make some optimization as the number of instances
are 2022
27 October unlimited. 39
Object Diagram
• The following things are to be decided before starting the
construction of the diagram:
– The object diagram should have a meaningful name to
indicate its purpose.
– The most important elements are to be identified.
– The association among objects should be clarified.
– Values of different elements need to be captured to include
in the object diagram.
27 October 2022 40
Sample Example
27 October 2022 41
Activity Diagram
• Activity diagram is another important diagram in UML to
describe the dynamic aspects of the system.
• Activity diagram is basically a flowchart to represent the flow
from one activity to another activity.
• The control flow is drawn from one operation to another. This
flow can be sequential, branched, or concurrent.
• Activity diagrams deal with all type of flow control by using
different elements such as fork, join, etc.
• The purpose of an activity diagram can be described as:
– Draw the activity flow of a system.
– Describe the sequence from one activity to another.
– Describe the parallel, branched and concurrent flow of the
system.
27 October 2022 42
Activity Diagram
• Activity diagrams are not exactly flowcharts as they have
some additional capabilities. These additional capabilities
include branching, parallel flow, swim lane, etc.
• The main element of an activity diagram is the activity itself.
• An activity is a function performed by the system. After
identifying the activities, we need to understand how they are
associated with constraints and conditions.
• Before drawing an activity diagram, we should identify the
following elements:
– Activities
– Association
– Conditions
– Swim lanes
27 October 2022 43
Sample Example: Withdrawal from ATM
27 October 2022 44
State-chart Diagram
• It describes different states of a component in a system. The
states are specific to a component/object of a system.
27 October 2022 45
State-chart Diagram
• State-chart diagram describes the flow of control from one
state to another state.
• States are defined as a condition in which an object exists and
it changes when some event is triggered.
• The most important purpose of State-chart diagram is to model
lifetime of an object from creation to termination.
• Following are the main purposes of using State-chart diagrams
– To model the dynamic aspect of a system.
– To model the life time of a reactive system.
– To describe different states of an object during its life time.
– Define a state machine to model the states of an object.
27 October 2022 46
Example: Withdrawal from ATM
27 October 2022 47
Interaction Diagrams
• This interactive behavior is represented in UML by two
diagrams known as Sequence diagram and Collaboration
diagram.
27 October 2022 48
Interaction Diagrams
• The purpose of interaction diagram is:
– To describe the message flow in the system.
– To describe the structural organization of the objects.
– To describe the interaction among objects.
27 October 2022 49
Sequence Diagram
27 October 2022 50
Collaboration Diagram
• In the collaboration diagram, the method call sequence is
indicated by some numbering technique.
27 October 2022 52
Component Diagram
• Component diagram is a special kind of diagram in UML. It
does not describe the functionality of the system but it
describes the components used to make those functionalities.
• Component diagrams can also be described as a static
implementation view of a system. Static implementation
represents the organization of the components at a particular
moment.
• They are used:
– to model the physical aspects of a system; such as
executables, libraries, files, documents, etc. which reside in
a node.
– to visualize the organization and relationships among
components in a system. These diagrams are also used to
make executable systems.
27 October 2022 53
Component Diagram
• Before drawing a component diagram, the following artifacts
are to be identified clearly:
– Files used in the system.
– Libraries and other artifacts relevant to the application.
– Relationships among the artifacts.
27 October 2022 54
Component Diagram
27 October 2022 55
Deployment Diagram
• Deployment diagrams are used to describe the static
deployment view of a system.
27 October 2022 56
Deployment Diagram
• Deployment diagrams are useful for system engineers.
27 October 2022 58
Object Oriented Design Pattern
• A pattern serves as a guide to create good design.
• A pattern has following four components:
– Problem
– Context in which problem occurs
– Solution
– Context in which the solution works.
• Some important patterns are as below:
– Expert
– Creator
– Controller
– Facade
– Model view separation
– Intermediary
27 October 2022 59
Design Patterns
• Expert:
– Problem: Which class should be responsible for doing
certain things?
– Solution: the class that has the necessary information to do
the job.
• Creator:
– Problem: Which class should be responsible for creating
new instance for a class?
– Solution: A class C1 can create an instance of class C2, if:
• C1 is an aggregation of objects of type C2
• C1 contains object of type C2
• C1 closely uses objects of type C2
• C1 has the data required to initialize the objects of type C2, when
they are created.
27 October 2022 60
Design Patterns
• Controller
– Problem: Who should be handling actor requirement?
– Solution: For every use case, a separate controller object.
• Facade
– Problem: How should the services be requested from a
service package?
– Solution: A class can be created which provides a common
interface to the services of the package.
• Model View Separation
– Problem: How should the non GUI classes communicate
with GUI classes?
– Solution: It says that the model objects should not have the
direct knowledge to the view object.
27 October 2022 61
Design Patterns
• Intermediary
– Problem: How should the client and server object interact
with each other?
– Solution:
• A proxy object, at the client side, can be defined which
is a local sit-in for the remore server object.
• This proxy is responsible for determining the server
address, communicating the server address, obtaining
the server response and passing that to the client.
• The proxy could have the same interface as the server so
that the client feels as if it is interacting directly with the
sever.
27 October 2022 62
Object Oriented Analysis and Design
• It refers to the method of developing an initial model of the
software from SRS document.
• The analysis model is refined into a design model that can be
implemented using a suitable object oriented programming
language.
GUI Use
Interacti
Prototy Case
on
pe Diagram
Diagram
Star
t
Cod
e