Unit2 - UML
Unit2 - UML
uctural
3
UML Behavioral Diagram vs. Structural Diagram
4
Class Diagram
It shows a set of
classes, interfaces,
and collaborations and
their relationships,
typically, found in
modeling object-
oriented systems.
5
uctural
Class Diagram
6
Class Diagram
•The class diagram depicts a static view of an application.
7
Class Diagram
•It shows the attributes, classes, functions, and
relationships to give an overview of the software system.
9
Components of a Class Diagram
The class diagram is made up of three sections:
10
Components of a Class Diagram
Upper Section: The upper section encompasses the name
of the class. A class is a representation of similar objects
that shares the same relationships, attributes and
operations. Some of the following rules that should be
taken into account while representing a class are given
below:
•Dependency
•Generalization
•Association
13
Relationships in Class Diagram
Dependency: A dependency is a semantic relationship
between two or more classes where a change in one class
cause changes in another class. It forms a weaker
relationship.
Payment Verification
14
Relationships in Class Diagram
Generalization: A generalization is a relationship
between a parent class (superclass) and a child class
(subclass). In this, the child class is inherited from the
parent class.
15
Relationships in Class Diagram
Association: It describes a static or physical
connection between two or more objects. It depicts
how many objects are there in the relationship.
16
Relationships in Class Diagram
Multiplicity in Association : It defines a specific range
of allowable instances of attributes. In case if a range
is not specified, one is considered as a default
multiplicity.
Multiplicity Indicators
For example, multiple patients are admitted to one
Exactly one 1
hospital.
Zero or more (unlimited) * (0..*)
One or more 1..*
Zero or one (optional association) 0..1 Multiplicity Indicators
Specified range 2..4
Multiple, disjoint ranges 2, 4..6, 8
•Exactly one 1
•Zero or more (unlimited) 0..*
•One or more 1..*
•Zero or one (optional association) 0..1
•Specified range 2..4
•Multiple, disjoint ranges 2, 4..6, 8
17
Relationships in Class Diagram
Aggregation: An aggregation is a subset of association,
which represents “has a” relationship. It is more
specific then association. It defines a part-whole or
part-of relationship. In this kind of relationship, the
child class can exist independently of its parent class.
The company encompasses a number of employees,
and even if one employee resigns, the company still
exists.
18
Relationships in Class Diagram
Composition: The composition is a subset of
aggregation. It portrays the dependency between the
parent and its child, which means if one part is
deleted, then the other part also gets discarded. It
represents a whole-part relationship.
A contact book consists of multiple contacts, and if you
delete the contact book, all the contacts will be lost.
19
Relationships in Class Diagram
20
Relationships in Class Diagram
21
Class Diagram for Library Management System
22
Class Diagram for Library Management System
23
Class Diagram
Abstract Classes
24
Class Diagram
Let us assume that we have an abstract class
named displacement with a method declared inside it, and
that method will be called as a drive (). Now, this abstract
class method can be implemented by any object, for
example, car, bike, scooter, cycle, etc.
25
How to draw a Class Diagram?
Some key points that are needed to keep in mind while
drawing a class diagram are given below:
27
Class Diagram of a Banking System
Classes in the system
Bank, Branch, Account, Savings Account, Current Account, Loan,
and Customer.
Relationships
A Bank “has–a” number of Branches − composition, 1 to many
A Branch “has–a” number of accounts − aggregation, 1 to many
Nking System
From the class Account, two classes have inherited, namely,
Savings Account and Current Account.
A Customer can have one Current Account − association, 1 to 1
A Customer can have one Savings Account − association, 1 to 1
A Branch “has–a” number of Loans − aggregation, 1 to many
A Customer can take many loans − association, 1 to many
28
Class Diagram of
ATM System
29
Component Diagram
It shows a set of
components and their
relationships that
illustrates the static
implementation view of
a system.
30
Component Diagram
•A component diagram is used to break down a large object-
oriented system into the smaller components, so as to make
them more manageable.
•Notation :-
31
uctural
32
Object Diagram
33
Object Diagram
It is used to represent an instance of a system at a particular
time.
Nking System
•Notation :-
34
Deployment Diagram
It is the specification of
software and hardware
used to deploy the library
system. It contains the
details and design which
will guide users on how
the system works in
reality. It consists of
nodes such as the
software itself, the users’
devices, and their
connections.
35
TCP / IP
ISP
ISP
HTTP(S)
Deployment Diagram
36
Deployment Diagram
•The deployment diagram shows the scenario when the
system is deployed.
An activity diagram
visually presents a
series of actions or
flow of control in a
system similar to a
flowchart or a data flow
diagram. But they are
not flow charts.
40
Purpose of Activity Diagram
•Draw the activity flow of a system.
41
Basic Symbols used in Activity Diagram
Initial State or Start Point
42
Basic Symbols used in Activity Diagram
Activity or Action State
43
Basic Symbols used in Activity Diagram
Action Flow
44
Basic Symbols used in Activity Diagram
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.
45
Basic Symbols used in Activity Diagram
Decisions and Branching - A diamond represents
a decision with alternate paths.
•When an activity requires a decision prior to
moving on to the next activity, add a diamond
between the two activities.
•The outgoing alternates should be labeled with a
condition or guard expression. You can also label
one of the paths "else."
46
Basic Symbols used in Activity Diagram
Guards - In UML, guards are a statement written
next to a decision diamond that must be true before
moving next to the next activity.
47
Basic Symbols used in Activity Diagram
Synchronization
48
Basic Symbols used in Activity Diagram
49
Basic Symbols used in Activity Diagram
Time Event
This refers to an event that stops the flow for a
time; an hourglass depicts it.
50
Basic Symbols used in Activity Diagram
Merge Event
A merge event brings together multiple flows that
are not concurrent.
51
Basic Symbols used in Activity Diagram
Sent and Received Signals - Signals represent
how activities can be modified from outside the
system.
•They usually appear in pairs of sent and
received signals, because the state can't change
until a response is received. For example, an
authorization of payment is needed before an order
can be completed.
52
Basic Symbols used in Activity Diagram
Interrupting Edge
An event, such as a cancellation, that interrupts the
flow denoted with a lightning bolt.
53
Basic Symbols used in Activity Diagram
Final State or End Point
An arrow pointing to a filled circle nested inside
another circle represents the final action state.
54
55
56
57
Basic Symbols used in Activity Diagram
Swimlanes - Swimlanes group related activities
into one column.
58
Basic Symbols used in Activity Diagram
Swimlanes
59
60
Merge Node
61
Where is the Activity Diagram used?
•Modeling work flow by using activities.
•Modeling business requirements.
•High level understanding of the system's
functionalities.
•Investigating business requirements at a later
stage.
62
Sequence Diagram
A sequence diagram
illustrates the
sequence of messages
between objects in an
interaction. A sequence
diagram consists of a
group of objects that are
represented by lifelines,
and the messages that
they exchange over time
during the interaction.
63
Sequence Diagram
•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.
65
Sequence Diagram Notations
•Lifelines – A lifeline is a named element which
depicts an individual participant in a sequence
diagram. So basically each instance in a
sequence diagram is represented by a life line.
66
Sequence Diagram Notations
•Messages – Communication between objects is
depicted using messages. The messages appear in
a sequential order on the lifeline. We represent
messages using arrows.
67
Activity Diagram vs. Sequence Diagram
nefits
68
Sequence diagram showing sequence of events
nefits
69
How to draw Sequence Diagram?
•Step 1: Think of the parts that make up whatever
your topic is. Eg. ATM Transaction - Withdrawal of
money.
ATM
Actor Bank
Bank Account
nefits Server
70
How to draw Sequence Diagram?
•Step 2: Draw Actors and objects in sequential order
from left to right.
nefits
71
How to draw Sequence Diagram?
•Step 3: Draw Lifelines – Lifelines are vertical dashed
lines that show the existence of an object or an actor
over time.
nefits
72
How to draw Sequence Diagram?
•Step 4: Initiate messages from left to right and
Alternative frame.
nefits
73
nefits
74
nefits
75
nefits
nefits
77
•Step 5: Add Activation boxes. Show when the object
is active and when its idle.
nefits
79
Communication/
Collaboration Diagram
The collaboration
diagram is used to show
the relationship between
the objects in a system.
It is used to portray the
architecture of objects in
the system.
80
Notations of Collaboration Diagram
A collaboration diagram resembles a flowchart that
portrays the roles, functionality and behavior of
individual objects as well as the overall operation of
the system in real time. The four major components of
a collaboration diagram are:
nefits
•Objects- Objects are shown as rectangles with
naming labels inside. The naming label follows the
convention of object name: class name.
83
Collaboration Diagram for ATM withdrawal
Acc:
84 Bank Account
When to use Collaboration Diagram
Collaboration diagrams should be used when the
relationships among objects are crucial to display.
Examples are as follows:
86
Difference between Sequence And Collaboration Diagram
87