UML (Unified Modelling Language) : Lecture-8

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

UML (Unified Modelling

Language)
Lecture-8
What is UML and Why we use
UML?
 UML → “Unified Modeling Language”
• UML is a language for:
– Specifying
– Visualizing and
– Documenting
the artifacts of a system under development
 Modeling: Describing a software system at a high level of
abstraction
 UML has been adopted by the OMG (Object Management
Group) as an OO notation standard
What is UML and Why we use
UML?
 Why we use UML?
 Use graphical notation: more clearly than natural language
(imprecise) and code (too detailed).

 Help acquire an overall view of a system.

 UML is not dependent on any one language or technology.


How to use UML diagrams to
design software system?
• Types of UML Diagrams:
 Use Case Diagram
 Class Diagram
 Sequence Diagram
 Collaboration Diagram
 State Transition Diagram
 Activity diagram
 Component diagram
 Deployment diagram
 Package diagram
Sequence Diagram
• Sequence diagrams model the interactions between
objects ( i.e. in a single use case).
• They illustrate how the different parts of a system
interact with each other to carry out a function and
the order in which the interactions occur when a
particular use case is executed.
• In simpler words, a sequence diagram shows
different parts of a system work in a ‘sequence’ to get
something done.
• It shows sequence of events occur

5
Sequence Diagram
Two major components
•Active Objects
•Communication between these active objects Messages send
between active objects
Active Objects
•Any object that play role in a system
•Participate by sending or receiving message
•Placed at top of the diagram
•Can be
•An Actor (from use case diagram)
•Object /class(from class diagram)

6
Sequence Diagram Notations –
• Actors – An actor 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.
•  stick person notation

7
Continued….
Lifelines –each instance in a sequence diagram is represented by a
lifeline.
•Lifeline elements are located at the top in a sequence diagram.
•The standard in UML for naming a lifeline follows the following format
– Instance Name : Class Name

8
Activation or Execution Occurrence

Activation or Execution Occurrence


•Activation boxes represent the time an object needs to complete a task.
When an object is busy executing a process or waiting for a reply
message, use a thin gray rectangle placed vertically on its lifeline.

9
Continued….
• Messages – Communication between objects is depicted using messages.
• The messages appear in a sequential order on the lifeline and represented by
arrows.
Synchronous messages – A synchronous message waits for a reply before the
interaction can move forward. The sender waits until the receiver has
completed the processing of the message. The caller continues only when it
knows that the receiver has processed the previous message i.e. it receives a
reply message. We use a solid arrow head to represent a synchronous message
• Asynchronous Messages – An asynchronous message does not wait for a
reply from the receiver. The interaction moves forward irrespective of the
receiver processing the previous message or not. We use a lined arrow head to
represent an asynchronous message.

10
Message Example

11
Message….
• Create message – We use a Create message to instantiate a new object in the sequence diagram.
There are situations when a particular message call requires the creation of an object. It is
represented with a dotted arrow and create word labelled on it to specify that it is the create Message
symbol.
For example – The creation of a new order on a e-commerce website would require a new object of
Order class to be created.
• Delete Message – We use a Delete Message to delete an object. When an object is deallocated
memory or is destroyed within the system we use the Delete Message symbol. It destroys the
occurrence of the object in the system. It is represented by an arrow terminating with a x.
For example – In the scenario below when the order is received by the user, the object of order class
can be destroyed.
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.

12
Create Message Delete Message

For example – The creation of a new order on a e- For example – In the scenario below when the
commerce website would require a new object of order is received by the user, the object of order
Order class to be created. class can be destroyed.

13
Messages--

Reply message

For example – Consider a scenario where the device wants to


access its webcam. Such a scenario is represented using a
self message .

Self Message

14
Guards
• To model conditions we use guards in UML. 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

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

16
17
Summary
• A sequence diagram simply depicts interaction
between objects in a sequential order i.e. the order
in which these interactions take place
• Sequence diagrams describe how and in what
order the objects in a system functions.

18
Online shopping scenario
• Online shopping scenario where customer
can place order.
• Order can be of two categories i.e. normal
order or special order

19
Use case diagram

20
Class diagram

21
Sequence Diagram

22
Activity Diagram

23
Login SD

24

You might also like