Chapter 2
Chapter 2
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
UML
It stands for Unified Modelling Language
UML
Cont…
4
UML
Cont…
5
UML
Cont…
6
Why Modeling?
Models make it easier to express complex ideas.
For example, an architect builds a model to
communicate ideas more easily to clients.
Models reduce complexity by separating those
aspects that are unimportant from those that are
important.
UML
Cont…
7
Advantages of Modeling
Models enhance learning.
The cost of the modeling analysis is much lower
than the cost of similar experimentation conducted
with a real system.
Manipulation of the model (changing variables) is
much easier than manipulating a real system.
UML
Cont…
8
UML
Cont.…
9
UML
Cont.…
10
UML
A Conceptual Model of the UML
11
UML
Building Blocks of the UML
12
UML
Building Blocks of the UML
14
Behavioral things
Grouping things
Annotation things
UML
Elements of UML
15
UML
Elements of UML
16
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,
UML
Elements of UML
17
Structural things
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
Elements of UML
18
UML
Elements of UML
19
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 with its name.
UML
Elements of UML
20
UML
Elements of UML
21
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?
UML
Elements of UML
23
Grouping things
Grouping things are the organizational parts of UML models.
These are the boxes into which a model can be decomposed.
Example; Packages.
What is a Package?
UML
Relationships in the UML
24
Dependency
Association
Generalization
Realization
UML
Relationships in the UML
25
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.
Dependency relationship
UML
Relationships in the UML
26
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.
Association relationship
UML
Relationships in the UML
27
UML
Relationships in the UML
28
UML
Relationships in the UML
29
UML
Relationships in the UML
30
UML
Relationships in the UML
31
Generalization relationship
UML
Relationships in the UML
32
Example of relationships:
UML
Modeling views
33
UML
Modeling views
34
Example Views
UML
Model views
35
UML DIAGRAM
UML
USE CASE DIAGRAM
38
Use-case Diagram:
Use case diagrams represent the
functionality of the system from a user’s
point of view.
A UML use case diagram shows the
relationships among actors and use cases
within a system.
UML
Use case Diagram
40
UML
Use case Diagram
41
UML
Use case Diagram
42
Use case
System Boundary
Relationship
Actor Relationship
UML
Use case Diagram
43
An Actor :
A person, organization, local process, external system
that plays a role in one or more interactions with a
system.
Something with a behavior or role, e.g., a
person, another system, organization.
UML
Use case Diagram
44
An Actor :
Actors are not part of the system.
Actors represent anything that interacts with the system
a human, a machine, or system.
Carry out use cases and a single actor may perform
more than one use cases.
UML notation for actor is stickman
Actor
UML
Use case Diagram
45
What Is an Actor?
Actors are EXTERNAL.
They can actively interchange information
with the system.
They can be a giver of information.
An actor may input information to the system
and receive information from the system.
UML
Use case Diagram
46
Other system:
The other system with which the system must interact.
UML
Use case Diagram
48
Use cases:
A requirements analysis concept
A case of a use of the system/product
Describes the system's actions from the user point of view
Dialogue between an actor and a system.
Describes a sequence of action that provide a measureable
value to an actor.
Each use case is a sequence of related transactions
performed by an actor and a system in dialogue.
UML
Use case Diagram
50
Use cases:
Use case models should be developed from the project
stakeholders point of view, not from the developers (often
technical) point of view.
It is a collection of related success and failure scenarios,
describing actors using the system to
support a goal.
Represents a major piece of functionality that is complete from
beginning to end.
A use case is drawn as a horizontal ellipse on a UML use case
diagram.
Use case
UML
Use case Diagram
51
UML
Use case Diagram
52
Case study-2:
Write at least four
use cases of Ambo University
Student recoding system?
Register
View grade
Submit grade
Approve grade
Add course materials
Take attendance
Add/drop course
UML
Use case Diagram
54
UML
Use case Diagram
55
System Boundary:
The rectangle around the use cases is called the
system boundary box.
It represents the boundaries between the physical
system and the actor who interact with the physical
system.
UML notation for System Boundary is rectangle
System Boundary
UML
Use case Diagram
56
UML
Use case Diagram
57
UML
Use case Diagram
58
UML
Use case Diagram
59
Relationships
There are several types of relationships that may appear
on a use case diagram
An association between an actor and a use case
UML
Use case Diagram
60
modeling elements
UML
Use case Diagram
61
UML
Use case Diagram
63
UML
Use case Diagram
64
The base use case may stand alone, but under certain conditions its
UML
Use case Diagram
65
Example- Relationship
UML
Use case Diagram
67
UML
Use case Diagram
68
Scenario
it is a set of actions performed to achieve a goal under
some conditions፤ Actions specified as a sequence of steps
A step is a logically complete action performed either by
the actor or the system
Two types of Scenarios
Main success Scenario: when things go normally and the goal
is achieved.
Alternatives Scenario: When things go wrong and goals
cannot be achieved.
UML
Use case Diagram
69
Generally, Each use case may include all or part of the following
UML
Use case Diagram
70
UML
Use case Diagram
73
UML
Use case Diagram
74
UML
UML Diagram
75
Class Diagram
UML
Class Diagram
76
UML
Class Diagram
77
Classes
Attributes
UML
Class Diagram
78
Class Name
The name of the class is the only required tag in the graphical
representation of a class.
attributes
operations
UML
Class Diagram
80
Class Attributes
Represent the state of an object of the class.
UML
Class Diagram
81
Class Attributes
Attributes (fields, instance variables)
UML
Class Diagram
82
UML
Class Diagram
83
Class Operations
Operations describe the class behavior and appear in the third
Person
compartment.
name : String
Type is the data type of the attribute or the data returned by the
address : Address
operation. birthdate : Date
ssn : Id
Define the way in which objects may interact.
eat
Operations are descriptions of behavioral or dynamic features of a
sleep
class. work
play
UML
Class Diagram
84
Name
Account_Name
- Customer_Name
- Balance Attributes
+addFunds( ) Operations
+withDraw( )
+transfer( )
UML
Class Diagram
85
Class relationship
In UML, object interconnections (logical or physical), are modeled
as relationships.
Dependencies
Generalizations
Associations
UML
Class Diagram
86
Generalization relationship
A generalization connects a subclass to its superclass.
It denotes an inheritance of attributes and behavior from the
superclass to the subclass and,
It indicates a specialization in the subclass of the more general
superclass.
UML
Class Diagram
87
Generalization relationship
Place Subclasses Below Super classes
Inheritance goes up
Subclass should inherit all of the attributes and operations of its super
class, a concept called pure inheritance
UML
Class Diagram
88
Dependency relationship
elements.
on each other.
Association relationship
If two classes need to communicate with each other, there must be link
between them. This is an association denotes that link.
We can indicate the multiplicity of an association by adding multiplicity.
The example indicates that a Student has one or more Instructors and
every Instructor has one or more Students:
We can also indicate the behavior of an object in an association (i.e., the
role of an object) using rolenames.
UML
Class Diagram
90
UML
Class Diagram - Example 1
91
UML
Class Diagram - Example 2
92
UML
Interaction Diagram
93
UML
Interaction Diagram
94
Verify that a use case description can be supported by the existing classes
Collaboration Diagrams
Sequence Diagram
UML
Sequence Diagram
95
Assign pieces of the use case behaviour to the objects in the form
of services.
UML
services.
Sequence Diagram
97
UML
Sequence Diagram
98
Components of sequence diagram: Name:Class
Objects
Object lifeline
Message
Activation Bar
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
Sequence Diagram
99
Messages
An interaction between two objects is performed as a message sent
If object obj1 sends a message to another object obj2 some link must
UML
Sequence Diagram
100
The sender will send the message and receiver will receive the
message.
Object life line are denoted as dashed lines. They are used to
model the existence of objects overtime.
UML
Sequence Diagram
101
Activation Bar:
UML
Sequence Diagram
102
UML
Sequence Diagram
103
member: :Book
book:Book
LibraryMember Copy
borrow(book)
ok = mayBorrow()
[ok] borrow(member)
setTaken(member)
Sequence Diagrams
Sequence Diagram
104
X-Axis (objects)
member: :Book
book:Book
LibraryMember Copy
borrow(book)
Life Object
ok = mayBorrow()
Y-Axis (time)
Line
message
Activation
[ok] borrow(member)
setTaken(member) box
condition
Sequence Diagrams
Sequence Diagram
105
Example- Login Use case
UML
Sequence Diagram
106
UML
Sequence Diagram
107
UML
Sequence Diagram
108
UML
Collaboration Diagram
109
UML Collaboration Diagram
Like UML sequence diagrams, it used to explore the dynamic nature
of a software.
UML
Collaboration Diagram
110
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
Collaboration Diagram
112
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
113
operations.
another activity.
UML
Activity Diagrams
114
Example:
UML
Activity Diagrams
115
Example:
UML
Deployment Diagrams
116
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
Deployment Diagrams
117
UML
Deployment Diagrams
118
UML
119
End!
UML