0% found this document useful (0 votes)
59 views

Unit2 - UML

The document discusses class diagrams in UML. It defines class diagrams and explains that they show the static structure of a system through classes, attributes, operations and relationships. The key components of a class diagram are described as the upper, middle and lower sections which define the class name, attributes and methods. Different relationships like dependency, generalization, association and their multiplicities are also explained. Examples of class diagrams for a library management system and banking system are provided.

Uploaded by

Sanjal Desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Unit2 - UML

The document discusses class diagrams in UML. It defines class diagrams and explains that they show the static structure of a system through classes, attributes, operations and relationships. The key components of a class diagram are described as the upper, middle and lower sections which define the class name, attributes and methods. Different relationships like dependency, generalization, association and their multiplicities are also explained. Examples of class diagrams for a library management system and banking system are provided.

Uploaded by

Sanjal Desai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 87

SE- Unit 2 UML

Roohana Parabia , M.Sc. (I.T.), VNSGU


UML
•Full form - Unified Modeling Language

•Definition - A UML diagram is a diagram based on


the UML (Unified Modeling Language) with the
purpose of visually representing a system along
with its main actors, roles, actions, artifacts or
classes, in order to better understand, alter,
maintain, or document information about the
system.

•It is widely used as a standard language


specifically for object oriented program.
2
UML Behavioral Diagram vs. Structural Diagram

uctural

3
UML Behavioral Diagram vs. Structural Diagram

Structural (or Static) view: emphasizes the static


structure of the system using objects, attributes,
operations and relationships. It includes class
diagrams, composite structure diagrams, etc.

Behavioral (or Dynamic) view: emphasizes the


dynamic behavior of the system by showing
collaborations among objects and changes to the
internal states of objects. This view includes
sequence diagrams, activity diagrams, state
machine diagrams, etc.

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.

• It represents the types of objects residing in the system


and the relationships between them.

•A class consists of its objects, and also it may inherit from


other classes.

•A class diagram is used to visualize, describe, document


various different aspects of the system, and also construct
executable software code.

7
Class Diagram
•It shows the attributes, classes, functions, and
relationships to give an overview of the software system.

•It constitutes class names, attributes, and functions in a


separate compartment that helps in software
development.

•Since it is a collection of classes, interfaces, associations,


collaborations, and constraints, it is termed as a structural
diagram.

•It is the only diagram that is widely used for construction,


and it can be mapped with object-oriented languages.
8
Purpose of Class Diagram
•It analyses and designs a static view of an
application.

•It describes the major responsibilities of a system.

•It is a base for component and deployment diagrams.

•It incorporates forward and reverse engineering.

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:

•Capitalize the initial letter of the class name.


•Place the class name in the center of the upper
section.
•A class name must be written in bold format.
•The name of the abstract class should be written in
italics format.
11
Components of a Class Diagram
Middle Section: The middle section constitutes the
attributes, which describe the quality of the class. The
attributes have the following characteristics:
•The attributes are written along with its visibility
factors, which are public (+), private (-), protected (#),
and package (~).
•The accessibility of an attribute of a class is illustrated
by the visibility factors.
•A meaningful name should be assigned to the
attribute, which will explain its usage inside the class.

Lower Section: The lower section contain methods or


operations. The methods are represented in the form of a
list, where each method is written in a single line. It
12 demonstrates how a class interacts with data.
Relationships in Class Diagram
There are three types of relations:-

•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.

In the following example, Payment is dependent on the


Verification.

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.

For example, The Current Account, Saving Account,


and Credit Account are the generalized form of Bank
Account.

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.

For example, a department is associated with the


college.

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

In the abstract class, no objects can be a direct entity


of the abstract class.

The abstract class can neither be declared nor be


instantiated.

It is used to find the functionalities across the classes.


The notation of the abstract class is similar to that of
class; the only difference is that the name of the class
is written in italics.

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:

•To describe a complete aspect of the system, it is suggested


to give a meaningful name to the class diagram.
•The objects and their relationships should be acknowledged
in advance.
•The attributes and methods (responsibilities) of each class
must be known.
•A minimum number of desired properties should be
specified as more number of the unwanted property will
lead to a complex diagram.
•The diagrams should be redrawn and reworked as many
times to make it correct before producing its final version.
26
Class Diagram for a
Banking system

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.

•A component is a single unit of the system, which is replaceable


and executable.
Nking System

•The implementation details of a component are hidden, and it


necessitates an interface to execute a function.

•Notation :-

31
uctural

Component Diagram for


Library Management System

32
Object Diagram

It shows a set of objects


and their relationships,
which is the static
snapshots of instances
of the things found in
class diagrams. ( static
view at a particular
instance of time.)

33
Object Diagram
It is used to represent an instance of a system at a particular
time.

It is similar to the class diagram.

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.

•The above diagram has 4 nodes represented with boxes and


components within. The Library Management System node
has the component of several databases such as books,
borrowers, and users. Then the librarian must be connected
to the network thru TCP/IP in order for them to access the
system.

•Additionally, the software is connected to an ISP which


enables it to pass data to the online server and then will be
accessed by the borrowers thru browsers also with the help
of URLs. Lastly, the Librarian and the Borrowers can
37 communicate with the use of ISP.
Package Diagram

It groups related UML


elements into a
collection of logically
related UML structure. It
is used for organizing
the class and use case
diagrams.
38
Package
Diagram
Activity Diagram

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.

•Describe the message flow from one activity to


another.

•Describe the sequential, parallel, branched and


concurrent flow of the system.

41
Basic Symbols used in Activity Diagram
Initial State or Start Point

•A small filled circle followed by an arrow


represents the initial action state or the start point
for any activity diagram.

•For activity diagram using swim lanes, make sure


the start point is placed in the top left corner of the
first column.

42
Basic Symbols used in Activity Diagram
Activity or Action State

An action state represents the non-interruptible


action of objects.

You can draw an action state in SmartDraw using a


rectangle with rounded corners.

43
Basic Symbols used in Activity Diagram
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.

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.

•These are not essential, but are useful when a


specific answer, such as "Yes, three labels are
printed," is needed before moving forward.

47
Basic Symbols used in Activity Diagram
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.

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.

•It is also called Cross – functional diagram.

•The activity diagram only represents the activities


being performed, but Swimlane describes who
does what in a process or activity performed.

58
Basic Symbols used in Activity Diagram
Swimlanes

•In the Swimlane diagram, the activity diagram is


divided according to the class responsible for
working or performing out these activities.

•It simply shows the connection and strong


communication between these lanes and is used to
highlight waste, redundancy, and inefficiency in a
process of an activity or program.

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.

•These diagrams are widely used by businessmen


and software developers to document and
understand requirements for new and existing
systems.
64
Sequence Diagram Notations
•Actors – An actor in a UML diagram represents
a type of role where it interacts with the system
and its objects.

•An actor is always outside the scope of the


system we aim to model using the UML diagram.

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.

•Actors- Actors are instances that invoke the


interaction in the diagram. Each actor has a name and
a role, with one actor initiating the entire use case.
81
Notations of Collaboration Diagram
•Links- Links connect objects with actors and are
depicted using a solid line between two elements.
Each link is an instance where messages can be sent.

•Messages- Messages between objects are shown as


a labeled arrow placed near a link. These messages
nefits
are communications between objects that convey
information about the activity and can include the
sequence number.

The most important objects are placed in the center


of the diagram, with all other participating objects
branching off.
82
nefits

83
Collaboration Diagram for ATM withdrawal

1. Insert Card 2. Verify Card


5. Pin Entered 6. Verify PIN
9. Amt Entered 10. Start Transaction
A: B:
ATM Bank Server
C:
4. Request PIN 3. Card OK
Customer
8. Request Amt 7. PIN OK
16. Dispense Cash nefits
15. Transaction successful
17. Eject Card

12. Funds OK 11. Sufficient


14. Withdraw funds?
successful 13. Withdraw
Amt

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:

•Modeling collaborations, mechanisms or the


structural organization within a system design.
nefits
•Providing an overview of collaborating objects within
an object-oriented system.

•Exhibiting many alternative scenarios for the same


use case.

•Visualizing the complex logic behind an operation.


85
Disadvantages of Collaboration Diagram

•As the number of objects and messages grows, a


collaboration diagram can become difficult to read and
use efficiently.

•It is a time-consuming diagram.


nefits
•Collaboration diagrams typically exclude descriptive
information, such as timing.

86
Difference between Sequence And Collaboration Diagram

Sequence Diagram Collaboration Diagram


1. It emphasizes the time and 1. It emphasizes the messages
order of events. exchanged between objects in
an application.
2.The sequence diagram are 2. The collaboration diagram are
used to represent the nefits
used to represent the structural
sequence of messages that organization of the system and
are flowing from one object to the messages that are sent and
another. received.

87

You might also like