You are on page 1of 117

CHAPTER THREE

MODELLING WITH UML

UML
Outline
2
Introduction
A Conceptual Model of the UML
An overview of UML Diagrams
 Use case diagram
 Class diagram
 Sequence diagram
 Activity diagram
 Deployment diagram

UML
Introduction
3

 Unified Modelling Language(UML)


UML is a model which has a collection of graphical
notation.
A model is a simplification of reality and it helps to
visualize requirements, permit specifications, and
document decision.
It is a language of visualizing, specifying, constructing
and documenting the arti-facts of software system.
 UML is a notation that resulted from the unification of
 OMT (Object Modelling Technique) and
 OOSE (Object-Oriented Software Engineering).
UML
Introduction(cont…)
4
 UML provides constructs for a broad range of
systems and activities (e.g., real-time systems,
distributed systems, analysis, system design,
deployment).
 System development focuses on three different
models :-
 The functional model- represented in UML with

use case diagrams.


 describes the functionality of the system from the
user’s point of view.
UML
Introduction(cont…)
5
 The object model- represented in UML with class
diagrams.
 describes the structure of a system in terms of
objects, attributes, associations, and operations.
 Represents the static structure of the system
 The dynamic model- represented in UML with
sequence diagrams, state chart diagrams, and activity
diagrams.
 describes the internal behaviour of the system.

UML
A Conceptual Model of the UML
6

 The three major elements that comprise the UML (conceptual


model of the UML) are:
 The UML’s basic building blocks
 The rules that dictate how those building blocks may be put
together, and
 Some common mechanisms that apply throughout the UML

Building Blocks of the UML


 The vocabulary of the UML encompasses three kinds of
building blocks:
 Things
 Relationships
 Diagrams
UML
Cont…
7

UML
THINGS
8

 Things are the abstractions that are first-class citizens in a


model; relationships tie these things together; diagrams
group interesting collections of things.
 Things in the UML
There are four kinds of things in the UML, which are
used to write well-formed models.
Structural things
Behavioral things
Grouping things
Annotation things

UML
Cont…
9

UML
Cont…
10
 Structural things
 Structural things are the nouns of the UML models. These are the
mostly static parts of a model, representing elements that are
either conceptual or physical.
 In all, there are seven kinds of structural things: Class, Interface,
Collaboration, Use Case, Active Classes, Components, and Nodes.
 What is a Class?
 A class is a description of objects that share the same attributes,
operations, relationships, and semantics. A class is represented
using a rectangle with compartments showing its name,
attributes, and operations.
 A class is an abstraction in that it emphasizes relevant
characteristics and suppresses other characteristics.
UML
Cont…
11

UML
Cont…
12

 What is an Interface?
 An interface is a collection of operations that specify a service of a
class or component.
 It defines a set of operation specifications (that is their signatures)
but never a set of operation implementations.
 Graphically an interface is rendered as a circle together with its
name. When an interface is shown as a circle, its operations are
suppressed.
 However, an interface can also be rendered as a stereotyped class
listing its operations in the appropriate compartment.

UML
Cont…
13
 What is a Collaboration?
 A collaboration defines an interaction and is a society of
roles and other elements that work together to provide some
cooperative behavior that is bigger than the sum of all the
elements.
 Thus, collaborations have structural, as well as behavioral
dimensions.
 What is a Use Case?
 A use case is a description of a set of sequence of actions that a

system performs that yields an observable result of value to a


particular actor.
 An actor represents anything that interacts with the system.
UML
Cont…
14
 A use case describes what a system does, but it does not specify
how it does it. A use case is realized by a collaboration.
 Graphically, a use case is rendered as an ellipse with solid lines,
including only its name.
Calculate
profit

Use case Actor

 What is an Active Class?


 An active class is a class whose objects own one or more
processes or threads and therefore can initiate control activity.

UML
Cont…
15
An active class is just like a class except that its objects
represent elements whose behavior is concurrent with
other elements. Graphically, an active class is rendered
just like a class, but with heavy lines.
 What is a Component?
 A component is a physical and replaceable part of a system that
conforms to and provides the realization of a set of interfaces.
 In a system, you will encounter different kinds of deployment
components, such as Java Beans, as well as components that
are artifacts of the development process, such as source code
files.

UML
Cont…
16
 What is a Node?
 A node is a physical element that exists at run time and
represents a computational resource, generally having at
least some memory and, often, processing capability.
 A set of components may reside on a node and may also
migrate from node to node.
 Graphically, a node is rendered as a cube, usually,
including only its name.

Server

UML
Cont…
17
 Behavioral things
 Behavioral things are the dynamic parts of UML models.
These are the verbs of a model, representing behavior over
time and space. In all, there are two primary kinds of
behavioral things: Interaction and State Machine.
 What is an Interaction?
 An interaction is a behavior that comprises a set of
messages exchanged among a set of objects within a
particular context to accomplish a specific purpose.
Graphically, a message is rendered as a directed line,
almost always including the name of its operation.
display
UML
Cont…
18

 What is a State Machine?


 A state machine is a behavior that specifies the sequence of states an
object or an interaction goes through during its lifetime in response
to events, together with its responses to those events.
 A state represents a particular set of values for an object
 A state machine involves a number of other elements in addition to
states:
 Transitions (the flow from state to state)

 Events (things that trigger a transition)


 Activities (the response to a transition)

 Graphically, a state is rendered as a rounded rectangle, usually


including its name and Its sub-states, if any,
Waits
UML
Cont…
19
 Grouping things
 Grouping things are the organizational parts of UML models.

These are the boxes into which a model can be decomposed. In


all, there is one primary kind of grouping thing: Packages.
 What is a Package?

 A package is a general-purpose mechanism for organizing


elements into groups. Structural things, behavioral things,
and even other grouping things may be placed in a package.
 Graphically a package is rendered as a tabbed folder, usually
including only its name and sometimes,
its contents.

UML
Cont…
20

 Annotation things
 Annotation things are the explanatory parts of UML models.

These are the comments you may apply to describe, illuminate,


and remark about any element in a model. In all, there is one
primary kind of annotation thing: note.
 What is a Note: A note is simply a symbol for rendering

constraints and comments attached to an element or a


collection of elements.
 Graphically a note is rendered as a rectangle with a dog-
eared corner, together with a textual or graphical comment.
 It may be anchored to

an element with a dashed line.


UML
Cont…
21

 Relationships in the UML


 There are four kinds of relationships in the UML:
 Dependency
 Association
 Generalization
 Realization
 What is a Dependency Relationship?

 A dependency relationship is a semantic relationship between


two model elements where a change in one may cause a
change in the other.
 Graphically, a dependency is rendered as a dashed line,
possibly directed, and occasionally including a label.
UML
Cont…
22

Dependency relationship
 What is an Association Relationship: An association is a structural
relationship that specifies that objects (instances of classes) are
connected to other objects.
 Graphically, an association is rendered as a solid line, possibly
directed, occasionally including a label, and often containing other
adornments, such as multiplicity and role names.
UML
Cont…
23

Association relationship
 Multiplicity is the number of instances of one class that
relate to one instance of another class.
 For each association, there are two multiplicity
decisions to make, one for each end of the association.
 For example, a Course Offering object may have either
zero or one Professor object related to it, and conversely
a Professor object may have zero or more Course
Offering objects related to it.
UML
Cont…
24

 Multiplicity is indicated by a text expression on the role.


 The expression is a comma-separated list of integer
ranges. A range is indicated by an integer (the lower
value), two dots, followed by another integer (the upper
value).
 Example-2:

UML
Cont…
25

UML
Cont…
26

 Aggregation is a special kind of association,


representing a structural relationship between an
aggregate (the whole) and its parts. An aggregation “Is-a-
part-of” relationship.
 There are many examples of aggregation relationships: a
Library contains Books, Departments are made up of
Employees, a Computer is composed of a number of
Devices.
 Graphically, a hollow diamond is attached to the end of an
association path on the side of the aggregate (the whole)
to indicate aggregation.
UML
Cont…
27

 What is a Generalization Relationship?


 A generalization is a specialization relationship, in which
objects of the specialized element (the child) are
substitutable for objects of the generalized element (the
parent).
 Generalization is an “Is-a-kind-of” relationship. You can
always test your generalization by applying the “Is-a-
kind-of” rule. You should always be able to say that your
specialized class “Is-a-kind-of” the parent class.
 Graphically, a generalization relationship is rendered as a
solid line with a hollow arrowhead pointing to the parent
as shown below.
UML
Cont…
28

Generalization relationship
UML
Cont…
29

 What is a Realization Relationship?


a semantic relationship between elements, wherein
one element specifies a contract and another
guarantees to carry out this contract.
Realization relationships are encountered in two places:
between interfaces and the classes or components that
realize them, and between use cases and the
collaborations that realize them.
 Graphically, a realization relationship can be rendered in two
forms: as a dashed line with a hollow arrow head pointing at the
contract classifier (canonical form), or when combined with an
interface (elided form).
UML
Cont…
30

 Example of relationships:

UML
Diagrams in UML
31

UML
Cont…
32
 Semantics of Diagrams
Use case diagram
Represent the functions of a system from the
user’s point of view
Sequence diagrams:
Represent the system’s behaviour in terms of
interactions among a set of objects.
Collaboration diagrams
A spatial representation of objects, links and
interactions
Emphasizes the structural organization of the
objects.
UML
Cont…
33
 Object Diagram
Represent objects and their relationships and
correspond to simplified collaboration diagrams that
does not represent message broadcasts
Class diagrams:
are used to represent the structure of a system in terms of
objects, their attributes, and relationships.
State chart diagrams:
 Represent the behavior of a class in terms of states
Shows a state machine, consisting of states, transitions,
events, and activities.

UML
Cont…
34

Activity diagrams:
 are flow diagrams used to represent the data flow or the
control flow through a system.
Component diagrams:
 Represent the logical components of an application.
 Shows the organization and dependencies among a set of
components
Deployment diagrams:
 Represent the deployment of components on particular
pieces of hardware.
 Shows the configuration of run-time processing nodes
and the components that live on them.
UML
Cont…
35

 In UML, a system is represented using five different


“views” that describe the system from distinctly different
perspectives.
 Each views is defined by a set of diagrams
 User model view: it represents the system(product) from

user’s (called actors in UML) perspective


 Structural model view: the data and functionality are

viewed from inside the system. That is, static structure


(classes, objects, and relationships) is modeled.
 Behavioural model view: it represent dynamic or
behavioural aspects of the system. It depicts the
interactions or collaboration between various structural
elements.
UML
Cont…
36

 Implementation model view: Structural and


behavioural aspect of the system as they are to be built.
 Environmental model view: The structural and
behavioural aspects of the environment in which the
system to be implemented.

UML
Cont…
37

 Readability guideline of UML


 Avoid crossing line
 Depict crossing line as a jump
 Avoid diagonal or curved lines
 Arrange symbols symmetrically
 Apply consistently sized symbols
 Include white space in diagrams
 Organize diagrams left to right , top to bottom

UML
Cont…
38

 Simplicity guideline of UML


 Show only what you have to show

 Prefer well known notation over esoteric notation

 Reorganize large diagrams in to several smaller ones

 Prefer single page diagrams

 Focus on content first, appearance second

 Describe diagrams with a note

 Apply consistent, readable font

UML
Use case Diagram
39
 A UML use case diagram shows the relationships
among actors and use cases within a system.
 Components of use case diagrams
Use case
Actor
System Boundary
Relationship
Actor Relationship

UML
Cont…
40

Use cases:
 Dialogue between an actor and a system.
 Each use case is a sequence of related transactions
performed by an actor and a system in dialogue.
 Describes a sequence of action that provide a
measureable value to an actor.
 A use case is drawn as a horizontal ellipse on a
UML use case diagram.
 Represents a major piece of functionality that is
complete from beginning to end.
UML
Use case diagram (cont…)
41

 Must deliver something of value to an actor.


 May be decomposed into other use cases.
 A good vehicle for project planning.
 They are often used to
Provide an overview of all or part of the usage
requirements for a system or organization in the
form of an essential model or a business model.
Communicate the scope of a development project.
Model the analysis of the usage requirements in the
form of a system use case model.
UML
Use case diagram (cont…)
42
 Use case models should be developed from the project
stakeholders point of view, not from the developers
(often technical) point of view.
 How do we find use cases?
 Ask following questions.

 What are the functions that the actor want from the
system?
 Does the system store information? Who will
create, read, update or delete that information.
 Does the system need to notify an actor about
UML
changes in its internal states?
Cont…
43

Case study-1: Write at least four use cases


of Ambo University Student recoding
system?

UML
Use case diagram (cont…)
44

 Guide lines of use case diagram


 Begin Use Case Names with a Strong Verb
 Example:

 Withdraw Funds, Register Student in Seminar, and


Deliver Shipment because it is clear what each use
case does.
 Use case names beginning with weak verbs such
as “process,” “perform,” and “do” are often
problematic
 Create communication difficulties with your project
stakeholders
UML
Use case diagram (cont…)
45

Because, the weak use cases such as Process


Withdrawal Transaction or Perform Student
Enrollment Request often indicate that:
 The use case was written with a technically oriented

view instead of a user-oriented view, and therefore


may be at risk of not reflecting the actual needs of
your project stakeholders.
UML
Use case diagram (cont…)
46

 Name Use Cases Using Domain Terminology

 The name of a use case should immediately convey


meaning to the project stakeholders.
 Example:
 Convey Package Via Vehicular Transportation is a generic

name for a use case


 But Deliver Shipment reflects common domain
terminology and therefore is more understandable.
UML
Use case diagram (cont…)
47

 Imply Timing Considerations by Stacking Use Cases


Use case diagrams should not reflect timing
considerations.
Increase the readability of the use case diagrams by
arranging use cases to imply timing.
Define preconditions in the use cases to describe
timing considerations.

UML
Use case diagram (cont…)
48
 An Actor :
A person, organization, local process, external
system that plays a role in one or more interactions
with a system
 Someone or something that must interact with the
system
 UML notation for actor is stickman

UML
Use case diagram (cont…)
49

 Plays user’s role with respect to system


 Not part of the system represent anyone or anything
that must interact with the system
 Carry out use cases and a single actor may perform
more than one use cases.
 Are determined by observing the direct uses of the
system
 An actor may input information to the system and
receive information from the system.

UML
Use case diagram (cont…)
50
 How do we find an actor?
 Ask the following questions
Who uses the system?
Who installs the system?
Who Starts up the system?
What other systems use this system?
Who gets the information from the system?
Who provides information to the system?
 Note: Actor is always external to the system. They are
never part of the system to be developed.
UML
Use case diagram (cont…)
51
 4-Categories of an actor:
 Principle
 Who uses the main system functions.
 Secondary
 Who takes care of administration and maintenance.

 External hardware
 devices which are part of application domain

Other system:
 The other system with which the system must

interact.
UML
Cont…
52

Case study-2: List the actors of Ambo


University Student recoding system?

UML
Use case diagram (cont…)
53
 Actor Guidelines
 Place your primary actor(s) in the top-left corner of the
diagram
 In western cultures, you start reading in the top-left

corner
 Directly involved with your primary/critical use cases

 Draw Actors on the Outside Edges of a Use Case


Diagram
 actors are outside your scope of control

 Name Actors with Singular, Domain-Relevant Nouns


 A name that accurately reflects its role within your model
UML
Use case diagram (cont…)
54

 Associate Each Actor with One or More Use cases


 Every actor is involved with at least one use case,
and every use case is involved with at least one actor
 Name Actors to Model Roles, Not Job Titles
 Example: Junior CSR ( Customer service
representative)
 Use <<system>> to Indicate System Actors

UML
Use case diagram (cont…)
55
 Don’t Allow Actors to Interact with One Another
The nature of the interaction between two actors will

be captured in the text of the use case , not


pictorially on the use case diagram
 Introduce an Actor Called “Time” to Initiate
Scheduled Events
 Certain events happen on a regular basis, payroll is

fulfilled every two weeks, bills are paid once a


month

UML
Use case diagram (cont…)
56

 Sample use case diagram

UML
Use case diagram (cont…)
57
 Relationship
 There are several types of relationships that may appear on
a use case diagram
 An association between an actor and a use case

 An association between two use cases,

 A generalization between two actors

 A generalization between two use cases

 Associations are depicted as lines connecting two modeling


elements
 Generalizations are depicted as close-headed arrow with the
arrow pointing toward the more general modeling element .
UML
Use case diagram (cont…)
58
 Relationship Guidelines
 Indicate an Association Between an Actor and a Use Case
if the Actor Appears within the Use Case Logic
 If an actor supplies information, initiates the use case, or

receives any information as a result of the use case, then


the corresponding use case diagram should depict an
association between the two
 Avoid Arrowheads on Actor-Use Case Relationships
 The arrowheads on actor-use associations indicate who or

what invokes the interaction.


 Indicated an arrowhead only when doing so provides

significant value.
UML
Use case diagram (cont…)
59

 Apply <<include>> When you Know Exactly When to


Invoke the Use Case
 The invocation of one use case by another one, just like

calling a function or invoking an operation within source


code
 All <<include>> associations, as well as <<extend>>

associations, are modeled as dependencies between use


cases and therefore a dashed line is used
 Apply <<extend>> When a Use Case May Be invoked
Across Several Use Case steps

UML
Use case diagram (cont…)
60
 An <<extend>> association is a generalization relationship
where the extending use case continues the behavior of the
base use case by conceptually inserting additional action
sequences into the base use case
 Apply <<extend>> Associations carefully
 Many use case modelers avoid the use of <<extend>>

associations because they have a tendency to make use


case diagrams difficult to understand.
 Avoid More Than Two Levels of Use Case
Associations

UML
Use case diagram (cont…)
61
 Place an Included Use Case to the Right of the Invoking
Use Case
 It is common convention to draw <<include>>
relationships horizontally, with the included use case to
the right of the invoking use case,
 Place an Extending Use Case Below the Parent Use Case
 It is common convention to draw <<extend>>
relationships vertically, with the extending use case
placed lower on your diagram than the base use case

UML
Use case diagram (cont…)
62
 Apply the “Is Like” Rule to Use Case Generalization
 The sentence “the [inheriting use case name] is like the [parent use
case name]” should make sense
 Place an Inheriting Use Case Below the Base Use Case
 It is a common convention to draw generalization relationships
vertically, with the inheriting use case placed lower on your diagram
than the parent use case
 Apply the “Is Like” Rule to Actor Inheritance
“the[inheriting actor name] is like the [parent actor name]”

 Place an Inheriting Actor Below the Parent Actor


 It is common convention to draw generalization relationship

vertically, with the inheriting actor placed lower on your


diagram than the parent actor
UML
Use case diagram (cont…)
63

Example:

UML
Use case diagram (cont…)
64
 System Boundary Box Guidelines:
 The rectangle around the use cases is called the
system boundary box.
 As the name suggests, it indicates the scope of your
system.
 The use cases inside the rectangle represent the
functionality that you intend to implement.
 Indicate Release Scope with a System Boundary Box
 Avoid Meaningless System Boundary Boxes

UML
Cont…
65

Case study-3: Draw the use case diagram


of Ambo University Student recoding
system?

UML
Use case diagram (cont…)
66
 Documenting Use Cases
 Generic format for documenting the use case:
Pre condition: If any

 Use case : Name of the case.


 Actors : List of actors(external agents), indicating who
initiates the use case.
 Purpose: Intention of the use case.
 Overview: Description.
 Type : primary / secondary.
 Post condition: If any
 Typical Course of Events(Flow of events):

ACTOR ACTION : Numbered actions of the actor.


SYSTEM RESPONSE : Numbered description of system responses.
UML
Use case diagram (cont…)
67

 Example: The following use case describes the process


of opening a new account
 Use case: Open new Account .
 Actors: Customer, Cashier, Manager
 Purpose: Like to have a new saving account
 Overview: A Customer arrives in the bank to open the

new account. Customer requests for the new


account form, fill the same and submits, along with the
minimal deposit. At the end of complete successful
process customer receives the passbook
 Type: primary use case

UML
Use case diagram (cont…)
68

 Normal Flow of Events


 For withdrawal of cash:
1. (SR) The ATM asks the user to insert a card.
2. (AA) The user inserts a cash card.
3. (SR) The ATM accepts the card and reads its serial number.
4. (SR) The ATM requests the password.
5. (AA) The user enters 1234.
6. (SR) The ATM verifies the serial number and password
with the bank and gets the notification accordingly.
7. (SA)The ATM asks the user to select the kind of
transaction.
8. (AA)User selects the withdrawal
UML
Use case diagram (cont…)
69

9. (SR)The ATM asks for the amount of cash; user enters Birr 200
10. (SR)The ATM verifies that the amount of cash is within predefined
policy limits and asks the bank, to process the transaction which
eventually confirms success and returns the new account balance.
11. (SR) The ATM dispenses cash and asks the user to take it.
12. (AA) The user takes the cash.
13. (SR) The ATM asks whether the user wants to continue.
14. (AA) The user indicates no.
15. (SR) The ATM prints a receipt, ejects the card and asks the user to
take them
16. (AA) The user takes the receipt and the card.
17. (SR) The ATM asks a user to insert a card.
UML
Use case diagram (cont…)
70

 Alternative Flow of Events


 For withdrawal of cash use case:
 9. The ATM asks for the amount of cash; the user

has change of mind and hits the “cancel”.


 Exceptional Flow of Events
 For withdrawal of cash use case:
 3. Suspicious pattern of usage on the card.

 10. The machine is out of cash.

 11. Money gets stuck in the machine.

UML
Cont…
71

Case study-4: Show the use case


documentation of Ambo University
Student recoding system?

UML
Class diagram
72

 Class diagram are used to represent the structure of


a system in terms of:-
Objects,
Their attributes, and
Relationships.
 It used for a variety of purpose, that is from
understanding your requirements to describing your
detailed design.

UML
Cont…
73

 Guidelines for Class diagram


 Identify Responsibilities on Domain Class Models
 When creating a domain class diagram, often as part of
your requirements modeling efforts, focus on
identifying responsibilities for classes instead of on
specific attributes or operations
 Indicate Visibility Only on Design Models
 The visibility of an operation or attribute defines the
level of access that objects have to it, and the UML
supports four types of visibility that are summarized in
the following table
UML
Cont…
74
 Visibility is an important design issue. On detailed design
models, you should always indicate the visibility of attributes
and operations.

UML
Cont…
75

 Sample object in analysis and design

UML
Cont…
76

 Be Consistent with Attribute Names and Types


 It would not be consistent for an attribute named customer-
Number to be a string, although it would make sense for it
to be an integer.
 Model Association Classes on Analysis Diagrams
 Association classes, also called link classes, are used to
model associations that have methods and attributes
 Association classes typically are modeled during analysis and
then re-factored during design.

UML
Cont…
77
 Center the Dashed Line of an Association Class
 The association path should be clearly connected to the path and

not to either class.


 Use Common Terminology for Class Names
 Class names should be based on commonly accepted

terminology to make them easier to understand by others.


 For business classes, this would include names based on

domain terminology such as Customer, OrderItem, and


Shipment etc
 For technical classes, names based on technical
terminology such as MessageQueue, ErrorLogger, and
PersistenceBroker.
UML
Cont…
78

 Prefer Complete Singular Nouns for Class Names


 Names such as Customer and PersistenceBroker are
preferable to Cust and PBroker,
 They are more descriptive and thus easier to understand

 Customer instead of Customers

 Name Operations with a Strong Verb

UML
Cont…
79

o Name Attributes with a Domain-Based Noun

UML
Cont…
80

 Never Show Classes with Just Two Compartments


Top-most compartment indicates name of the class

 Compartment typically lists the attributes; and the

third optional compartment typically lists the


operations
Include an Ellipsis ( . . . ) at the End of Incomplete
Lists.
List Operations/Attributes in Decreasing Visibility
 The greater the visibility of an operation or attribute,

the greater the chance that someone else will be


interested in it.
UML
Cont…
81
 Develop Consistent Operation and Attribute Signatures
 Operation names should be consistent with one another
 Parameter names such as the FirstName, firstName, and
firstNm are not consistent with one another, nor are
firstName, aPhoneNumber, and theStudentNumber
 Indicate Exceptions in an Operation’s Property String
 Some languages, such as Java, allow operations to throw
exceptions to indicate that an error condition has occurred.
Exceptions can be indicated with a UML property string
 Example

UML
Cont…
82
 Always Indicate the Multiplicity
 For each class involved in a relationship, there will always be
a multiplicity for it

UML
Cont…
83

 Place Subclasses Below Super classes


Inheritance goes up

 A Subclass Should Inherit Everything


 Subclass should inherit all of the attributes and

operations of its super class, and therefore all of its


relationships as well - a concept called pure
inheritance
 The advantage of pure inheritance is that you only

have to understand what a subclass inherits, and not


what it does not inherit.

UML
Cont…
84

UML
Sequence Diagram
85
 Sequence diagrams describe behaviour as a
sequence of messages exchanged among a set of
objects.
 It describe patterns of communication among a set
of interacting objects.
 An object interacts with another object by sending
messages.
 The reception of a message by an object triggers the
execution of an operation.

UML
Cont…
86
 Typically, we use a sequence diagram to:
 Describe the event flow of a use case.
Identify the objects that participate in the use case
Assign pieces of the use case behaviour to the objects
in the form of services.
 This process often leads to refinements in the use case
(e.g., correcting ambiguous descriptions, adding
missing behaviour) and consequently, the discovery of
more objects and more services.

UML
Cont…
87

 Shows object interaction arranged in time sequence.


 They show sequence of messages among the objects.
 It has two dimensions, vertical represents time &
horizontal represents objects
 detect bottlenecks within an object-oriented design. By
looking at what messages are being sent to an object, and
by looking at roughly how long it takes to run the
invoked method, you quickly get an understanding of
where you nee to change your design to distribute the
load within your system

UML
Cont…
88
 Components of sequence diagram: Name:Class

 Objects

 Object lifeline

 Message

 pre/post conditions.

 Object are represented by rectangles and name of the


objects are underlined
 Object life line are denoted as dashed lines. They are
used to model the existence of objects overtime.

UML
Cont…
89

 Messages are used to model the content of


communication between objects.
 They are used to convey information between objects
and enable object request services of other objects
 The message instance has a sender, receiver, and possible
other information according to the characteristics of the
request
 Messages are denoted as labelled horizontal arrows
between life lines.
 The sender will send the message and receiver will
receive the message.
UML
Cont…
90
Example: For withdrawal of cash(Normal Flow)
:Customer :ATM :Bank
Insert card
Request password
Enter the password
Verify account
Account o.k.
Request option
Enter option Create

Request amount
Transaction :Transaction
Enter the amount
Update transaction
Transaction commit
Transaction
Dispense cash complete
Request take cash
Take cash
Request continuation

Terminate
Print receipt ,eject card
Request take card
Take card
Display main screen and prompt for the card.

UML
Cont…
91

 General Guidelines of sequence diagram


 Strive for Left-to-Right Ordering of Messages
 Strive to arrange the classifiers (actors, classes, objects,

and use cases) across the top of your diagram in such a


way as to depict message flow from left to right.
 Give an Actor the Same Name as a Class, if Necessary
 Example: an actor named Student and a class named

Student. This is perfectly fine because the two classifiers


represent two different concepts.
 The actor represents the student in the real world whereas the
class represents the student within the business application that
you are building.

UML
Cont…
92

UML
Cont…
93

 Place Proactive System Actors on the Left-Most Side of Your


Diagram
 Actors that initiate interaction with yours – focus of what you

are modeling , eg. for business applications , actor person, org.


 Place Reactive System Actors on the Right-Most Side of
Your Diagram.
 Reactive system actors - systems that initiate interaction

with yours.
 For many business applications, these actors are treated as

“back-end entities,”
 System interacts with through access techniques such as C

APIs, Web services etc


UML
Cont…
94

 Name Objects When You Reference Them in


Messages
 Objects on sequence diagrams have labels in the

standard UML format “name: ClassName”


 where “name” is optional

 objects that have a name are called named objects,

whereas those without names are called anonymous


objects
 Name Objects When Several of the Same Type Exist
 Give name whenever the diagram includes several

objects of the same type


UML
Cont…
95

UML
Cont…
96
 Apply Textual Stereotypes to Classifiers
Consistently
 Don’t invest a lot of time agonizing over which

stereotypes you should use—for example, <<JSP>>


and <<java server page>> are both fine—just choose
one and apply it consistently.
 Focus on Critical Interactions
 critical aspects of your system when you are creating

a model and not to include extraneous details

UML
Cont…
97

 Justify Message Names Beside the Arrowhead


 Most modelers will justify message names, such as

calculateTotal() in Figure so that they are aligned


with the arrowhead.

UML
Cont…
98
 UML Collaboration Diagram
 Like UML sequence diagrams, it used to explore the

dynamic nature of a software.


 Collaboration diagrams show the message flow between

objects in an object-oriented application, and also imply


the basic associations (relationships) between classes
 Unlike sequence diagram the time is not explicitly

represented in these diagram


 The sequence of messages is indicated by numbering the

messages.

UML
Cont…
99
 Components of collaboration diagram
 Named objects

 Links: by a continuous line between objects, and indicates the

exchange of messages
 Messages has following attributes

 Synchronization --thread name, step within thread.


 Sequence number
 Message labels : The name of the message often corresponds
to an operation defined in the class of the object that is the
destination of the message. Message names may have the
arguments and return values.
 *[iteration]. It uses decimal notation.
 Message direction.
UML
Cont…
100

 Semantics of components:
 Object names identify which objects are participating

and the links show which objects collaborate


 A link between two objects must exist for one object to

send message to another and vice a versa.


 Messages in the collaboration diagram get transformed

to more detailed signature.


 They use the decimal notation system for numbering the

messages.
 The direction of the message defines the sender and

receiver of the message


UML
Cont…
101
1. Insert card
3. Enter password,
7. Enter kind
8. Create Transaction
10. Enter amount,
12. Transaction complete
15. Take cash, Take card
17. cancel, Terminate

CUST- TRANSA-
ATM CTION
OMER
2. request password,
6. request kind,
9. request amount,
13. Transaction succeed
14. dispense cash, request take cash
5. account ok.
16. request continuation,
18. print receipt, request take card
4. Verify account,
19. Display main screen
11. process transaction

BANK
Collaboration Diagram
UML
Activity diagrams
102
 It is the UML for modeling the dynamic aspects of
systems.
 An activity diagrams is essentially a flowchart, showing
flow of control from activity to activity.
 Activities are states that represent the execution of a set of
operations.
 The completion of these operations triggers a transition to
another activity.
 It can be described as an operation of the system.
 So the control flow is drawn from one operation to another.
 This flow can be sequential, branched or concurrent.
UML
Cont…
103
Activity is a particular operation of the system.
Activity diagrams are not only used for visualizing
dynamic nature of a system, but also used to construct the executable
system by using forward and reverse engineering techniques.
The only missing thing in activity diagram is the
message part.
 Before drawing an activity diagram we should identify the
following elements:
 Activities

 Association

 Conditions

 Constraints

UML
Cont…
104
 Example of an activity diagram for order management system.
 In the diagram four activities are identified which are associated
with conditions.
 One important point should be clearly understood that an activity
diagram cannot be exactly matched with the code.
 The activity diagram is made to understand the flow of activities
and mainly used by the business users.
 Some of the main activities are:
 Send order by the customer
 Receipt of the order
 Confirm order
 Dispatch order

UML
Cont…
105

After receiving the order request condition, checks are


performed to check if it is normal or special
order.
After the type of order is identified dispatch activity is
performed and that is marked as the termination of the
process.

UML
Cont…
106

UML
Cont…
107

Example:

UML
Component Diagram
108

 Component diagrams are used to model physical aspects of a


system.
 Now the question is what are these physical aspects?
 Physical aspects are the elements like executables, libraries,
files, documents etc which resides in a node.
 It used to visualize the organization and relationships among
components in a system
 It does not describe the functionality of the system but it
describes the components used to make those functionalities.
 It used during the implementation phase of an application. But it
is prepared well in advance to visualize the implementation
details.
UML
Cont…
109
So 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.
Now after identifying the artifacts the following points
needs to be followed:
 Use a meaningful name to identify the component for which the
diagram is to be drawn.
 Prepare a mental layout before producing using tools.
 Use notes for clarifying important points.

UML
Cont…
110

Example: a component diagram for order management


system. Here the artifacts are files. So the diagram shows
the files in the application and their relationships.

UML
Cont…
111
 UML deployment diagrams
 UML deployment diagram is used to describe the
relationship among run-time components and hardware
nodes.
 It show the configuration of run-time processing elements
and the software components, processes, and objects that
execute on them.
 It provides the necessary environment for the components to
execute in.
 A UML deployment diagram representing the allocation of
components to different nodes and the dependencies among
components
UML
Cont…
112

It used to visualize the topology of the physical


components of a system where the software
components are deployed.
The purpose of deployment diagrams can be
described as:
 Visualize hardware topology of a system.
 Describe the hardware components used to deploy
software components.
 Describe runtime processing nodes.

UML
Cont…
113
Deployment diagrams are useful for system engineers.
An efficient deployment diagram is very important because
it controls the following parameters:
 Performance
 Scalability
 Maintainability
 Portability
So before drawing a deployment diagram the following
artifacts should be identified:
 Nodes
 Relationships among nodes

UML
Cont…
114

Example: Web browsers on PCs and Macs can access a


Web Server that provides information from a Database.

UML
Cont…
115

UML
116

END
UML
Cont…
117

UML

You might also like