Software Engineering
Chapter Two: UML
Unified Modeling Language
During the early 90s, there were around 50 O-O methods, among
them:
Booch: Categories and Subsystems
Coad and Yourdon: Class, Object, Class-&-Object
Jacobson: Use cases, and OOSE
Rumbaugh: Class and Associations, and OMT
Then in 1995, Rational Software brought three industry leaders together to
create a single approach to object-oriented systems development.
Grady Booch, Ivar Jacobson, and James Rumbaugh (the three amigos)
worked with others to create a standard set of diagramming techniques
known as the Unified Modeling Language (UML).
Object Oriented System Analysis and Design 05/11/23 2
Unified Modeling Language
The objective of UML is to provide a common vocabulary of object
oriented terms and diagramming techniques that are rich enough to
model any systems development project from analysis through
implementation.
In November 1997, the Object Management Group (OMG) formally
accepted UML as the standard for all object developers. Over the
years since, the UML has gone through multiple minor revisions.
After several modifications through the years the recently released
version of UML is Version 2.5
Object Oriented System Analysis and Design 05/11/23 3
Unified Modeling Language
UML specification defines two major kinds of UML diagram: structure
diagrams and behavior diagrams.
Structure diagrams show the static structure of the system and its parts
on different abstraction and implementation levels and how they are
related to each other. The elements in a structure diagram represent the
meaningful concepts of a system, and may include abstract, real world
and implementation concepts.
Behavior diagrams show the dynamic behavior of the objects in a
system, which can be described as a series of changes to the system
over time.
Object Oriented System Analysis and Design 05/11/23 4
Unified Modeling Language
In addition to the two main categories UML defines four structural
relationships between things:
Dependency (uses): A vehicle uses fuel
Aggregation (has a): A car has axles
Association: This vehicle is licensed by the California
Department of Motor Vehicles
Generalization (is a): A car is a vehicle
UML 2.5 diagrams could be categorized hierarchically as shown
below. Note, items shown in blue are not part of official UML 2.5
taxonomy of diagrams.
Object Oriented System Analysis and Design 05/11/23 5
Object Oriented System Analysis and Design 05/11/23 6
Unified Modeling Language: Notations
Class:
A class is used to represent various objects. It is used to define the properties
and operations of an object. In UML, we can also represent an abstract class. A
class whose functionalities are not defined is called an abstract class. Any UML
class notation is generally expressed as follows,
Object Oriented System Analysis and Design 05/11/23 7
Unified Modeling Language: Notations
Object:
An object is an entity which is used to describe the behavior and functions of a
system. The class and object have the same notations. The only difference is that
an object name is always underlined in UML.
The notation of any object in UML is given below.
Object Oriented System Analysis and Design 05/11/23 8
Unified Modeling Language: Notations
Interface:
An interface is similar to a template without implementation details. A circle
notation represents it. When a class implements an interface, its functionality is
also implemented.
Object Oriented System Analysis and Design 05/11/23 9
Unified Modeling Language: Notations
Use-case:
Use-cases are one of the core concepts of object-oriented modeling. They are
used to represent high-level functionalities and how the user will handle the
system.
Object Oriented System Analysis and Design 05/11/23 10
Unified Modeling Language: Notations
Actor:
It is used inside use case diagrams. The actor is an entity that interacts with the
system. A user is the best example of an actor. The actor notation in UML is given
below.
Object Oriented System Analysis and Design 05/11/23 11
Unified Modeling Language: Notations
Component:
A component notation is used to represent a part of the system. It is denoted in
UML like given below,
Object Oriented System Analysis and Design 05/11/23 12
Unified Modeling Language: Notations
Node:
A node is used to describe the physical part of a system. A node can be used to
represent a network, server, routers, etc. Its notation is given below.
Object Oriented System Analysis and Design 05/11/23 13
Unified Modeling Language: Notations
Deployment diagram:
It represents the physical hardware on which system is installed. A
deployment diagram represents the physical view of a system. It
denotes the communication and interaction between various parts
of the system.
A deployment diagram consists of the following notations:
A node, A component, An artifact and An interface
Object Oriented System Analysis and Design 05/11/23 14
Unified Modeling Language: Notations
State machine:
It used to describe various states of a single component throughout the software
development life cycle. It is used to capture different states of a system
component.
Object Oriented System Analysis and Design 05/11/23 15
Unified Modeling Language: Notations
Activity diagram:
An activity diagram is used to represent various activities carried out by different
components of a system. It is denoted the same as that of the state machine
diagram. Activity diagram mainly contains initial state, final state, a decision box,
and an action notation.
Object Oriented System Analysis and Design 05/11/23 16
Unified Modeling Language: Notations
Sequence diagram
It is an interaction diagram which is used to visualize the message flow between
various components of a system. A sequence diagram particularly shows
interactions between one or more lifelines within real time. The notation of a
sequence diagram is given below,
Object Oriented System Analysis and Design 05/11/23 17
Unified Modeling Language: Notations
Package
which is used to group semantically related modeling elements into a single
cohesive unit. The package is the only grouping thing available in the UML.,
Object Oriented System Analysis and Design 05/11/23 18
Unified Modeling Language: Notations
Annotational things
It is like a note, which may be written to the model to capture some vital
information. It is similar to the yellow sticky note.
Object Oriented System Analysis and Design 05/11/23 19
Unified Modeling Language: Notations
Association relationship
It is a set of links that connect elements of the UML model. It also defines how
many objects are taking part in that relation. It illustrates how many elements are
participating in a particular interaction.
It is denoted as a dotted line with arrowheads on both sides. Both the sides contain
an element which describes the relationship. A new term multiplicity is introduced
that tells us how many objects of a particular element are associated.
Association relationship is denoted as follows,
Object Oriented System Analysis and Design 05/11/23 20
Unified Modeling Language: Notations
Dependency relationship
In this kind of a relationship, the source element is dependent upon the target
element and may be affected by changes to it. It is one of the most important
notations of UML. It defines the direction of a dependency from one object to
another.
It is denoted by a dotted line with an arrow at one side.
Dependency relationship is denoted as follows,
Object Oriented System Analysis and Design 05/11/23 21
Unified Modeling Language: Notations
Generalization relationship
It is also called as a parent-child relationship. It is a relationship between a general
thing and a more specific kind of a thing. This type of relationship is used to
represent the inheritance concept.
It is denoted by a straight line with a hollow arrowhead at one side.
Generalization relationship is denoted as follows,
Object Oriented System Analysis and Design 05/11/23 22
Summary of UML artifacts and when to use them in system development
Object Oriented System Analysis and Design 05/11/23 23
More on UML…..
Outline
What is UML and why we use UML?
How to use UML diagrams to design software system?
What UML Modeling tools we use today?
What is UML and Why we use
UML?
UML → “Unified Modeling Language”
Language: express idea, not a methodology
Modeling: Describing a software system at a
high level of abstraction
Unified: UML has become a world standard
Object Management Group (OMG): www.omg.org
What is UML and Why we use
UML?
More description about UML:
It is a industry-standard graphical language for
specifying, visualizing, constructing, and documenting the
artifacts of software systems
The UML uses mostly graphical notations to express the
OO analysis and design of software projects.
Simplifies the complex process of software design
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.
UML moves us from fragmentation to standardization.
What is UML and Why we use
UML?
Year Version
2003: UML 2.0
2001: UML 1.4
1999: UML 1.3
1997: UML 1.0, 1.1
1996: UML 0.9 & 0.91
1995: Unified Method 0.8
Booch ‘93 OMT - 2
Other methods
Booch ‘91
OMT - 1
How to use UML diagrams to
design software system?
Types of UML Diagrams:
Use Case Diagram
Class Diagram
Sequence Diagram
Collaboration Diagram
State Diagram
This is only a subset of diagrams … but are most widely
used
Use-Case Diagrams
A use-case diagram is a set of use cases
A use case is a model of the interaction
between
External users of a software product (actors) and
The software product itself
More precisely, an actor is a user playing a specific role
describing a set of user scenarios
capturing user requirements
contract between end user and software
developers
Use-Case Diagrams
Boundary Use Case
Actor Library System
Borrow Employee
Client
Order Title
Fine Remittance
Supervisor
Use-Case Diagrams
Actors: A role that a user plays with respect to the system, including human users
and other systems. e.g., inanimate physical objects (e.g. robot); an external system
that needs some information from the current system.
Use case: A set of scenarios that describing an interaction between a user and a
system, including alternatives.
System boundary: rectangle diagram representing the boundary between the
actors and the system.
Use-Case Diagrams
Association:
communication between an actor and a use case; Represented by
a solid line.
Generalization: relationship between one general use case
and a special use case (used for defining special alternatives)
Represented by a line with a triangular arrow head toward the
parent use case.
Use-Case Diagrams
Include: a dotted line labeled <<include>> beginning at base
use case and ending with an arrows pointing to the include use
case. The include relationship occurs when a chunk of
behavior is similar across more than one use case. Use
“include” in stead of copying the description of that behavior.
<<include>>
Extend: a dotted line labeled <<extend>> with an arrow toward
the base case. The extending use case may add behavior to the
base use case. The base class declares “extension points”.
<<extend>>
Use-Case Diagrams
Figure 16.12
The McGraw-Hill Companies, 2005
Use-Case Diagrams
Both Make Appointment
and Request Medication
include Check Patient
Record as a subtask
(include)
The extension point is
written inside the base
case Pay bill; the
extending class Defer
payment adds the
behavior of this extension
point. (extend)
Pay Bill is a parent use
case and Bill Insurance
is the child use case.
(generalization)
(TogetherSoft, Inc)
Class diagram
A class diagram depicts classes and their interrelationships
Used for describing structure and behavior in the use cases
Provide a conceptual model of the system in terms of
entities and their relationships
Used for requirement capture, end-user interaction
Detailed class diagrams are used for developers
Class diagram
Each class is represented by a rectangle subdivided into
three compartments
Name
Attributes
Operations
Modifiers are used to indicate visibility of attributes and
operations.
‘+’ is used to denote Public visibility (everyone)
‘#’ is used to denote Protected visibility (friends and
derived)
‘-’ is used to denote Private visibility (no one)
By default, attributes are hidden and operations are visible.
Class diagram
Name
Account_Name
- Customer_Name
Attributes
- Balance
+addFunds( ) Operations
+withDraw( )
+transfer( )
OO Relationships
There are two kinds of Relationships
Generalization (parent-child relationship)
Association (student enrolls in course)
Associations can be further classified as
Aggregation
Composition
OO Relationships: Generalization
Supertype Example: Customer
Regular Loyalty
Customer Customer
Subtype1 Subtype2
-Inheritance is a required feature of object orientation
-Generalization expresses a parent/child relationship among related classes.
-Used for abstracting details in several layers
OO Relationships: Association
Represent relationship between instances of classes
Student enrolls in a course
Courses have students
Courses have exams
Etc.
Association has two ends
Role names (e.g. enrolls)
Multiplicity (e.g. One course can have many students)
Navigability (unidirectional, bidirectional)
Association: Multiplicity and Roles
student
1 *
University Person
0..1 *
employer teacher
Multiplicity Role
Symbol Meaning
1 One and only one
Role
0..1 Zero or one “A given university groups many people;
some act as students, others as teachers.
M..N From M to N (natural
language) A given student belongs to a single
university; a given teacher may or may not
* From zero to any positive
be working for the university at a particular
integer
time.”
0..* From zero to any positive
integer
1..* From one to any positive
Class diagram
[from UML Distilled Third Edition]
Association: Model to Implementation
* 4
Student Course
has enrolls
Class Student {
Course enrolls[4];
}
Class Course {
Student have[];
}
OO Relationships: Composition
Whole Class
Class W Association
Models the part–whole relationship
Composition
Class P1 Class P2 Also models the part–whole relationship but, in
addition, Every part may belong to only one
whole, and If the whole is deleted, so are the
Part Classes parts
[From Dr.David A. Workman]
Example Example:
A number of different chess boards: Each square
belongs to only one board. If a chess board is
thrown away, all 64 squares on that board go as
well.
Figure 16.7
The McGraw-Hill Companies, 2005
OO Relationships: Aggregation
Container Class
Aggregation:
Class C expresses a relationship among instances of related
classes. It is a specific kind of Container-Containee
AGGREGATION
relationship.
Class E1 Class E2 express a more informal relationship than
composition expresses.
Containee Classes Aggregation is appropriate when Container and
Containees have no special access privileges to
each other.
Example
Bag
Apples Milk
[From Dr.David A. Workman]
Aggregation vs. Composition
Composition is really a strong form of association
components have only one owner
components cannot exist independent of their owner
components live or die with their owner
e.g. Each car has an engine that can not be shared with other cars.
Aggregations
may form "part of" the association, but may not be essential to it. They
may also exist independent of the aggregate. e.g. Apples may exist
independent of the bag.
Good Practice: CRC Card
Class Responsibility Collaborator
easy to describe how classes work by moving cards
around; allows to quickly consider alternatives.
Interaction Diagrams
showhow objects interact with one
another
UML supports two types of
interaction diagrams
Sequence diagrams
Collaboration diagrams
Sequence Diagram(make a phone
call)
Caller Phone Recipient
Picks up
Dial tone
Dial
Ring notification Ring
Picks up
Hello
Sequence Diagram:Object interaction
A B
Self-Call:
Self-Call A message that an
Synchronous
Object sends to itself.
Condition: indicates when a Asynchronous
message is sent. The message is
Transmission
sent only if the condition is true. delayed
[condition] remove()
Condition
*[for each] remove()
Iteration
Self-Call
Sequence Diagrams – Object Life Spans
Creation
Create message A
Object life starts at that point
Activation Create
B
Symbolized by rectangular stripes
Place on the lifeline where object is
activated.
Rectangle also denotes when object is
deactivated.
Deletion
Activation bar
X
Placing an ‘X’ on lifeline Return
Deletion
Object’s life ends at that point
Lifeline
Sequence Diagram
Us er
Message Catalog Res ervations
•Sequence diagrams demonstrate the
behavior of objects in a use case by 1: look up ()
describing the objects and the 2: title data ()
messages they pass.
3: [not available] res erve title ()
4 : title returned ()
•The horizontal dimension shows the
objects participating in the interaction. 5: hold title ()
5 : title available ()
•The vertical arrangement of 6 : borrow title ()
messages indicates their order.
6 : rem ove res ervation ()
•The labels may contain the seq. # to
indicate concurrency.
Interaction Diagrams: Collaboration diagrams
start
6: remove reservation
3 : [not available] reserve title
User Reservations
5: title available
6 : borrow title
1: look up
2: title data
4 : title returned
Catalog
5 : hold title
Collaboration diagrams are equivalent to sequence diagrams. All the features of sequence
diagrams are equally applicable to collaboration diagrams
Use a sequence diagram when the transfer of information is the focus of attention
Use a collaboration diagram when concentrating on the classes
State Diagrams (Billing Example)
State Diagrams show the sequences of states an object goes through
during its life cycle in response to stimuli, together with its responses and
actions; an abstraction of all possible behaviors.
Start End
Unpaid Paid
Invoice created payin Invoice destroying
g
State Diagrams (Traffic light
example)
Traffic Light Start
State
Transition Red
Yellow
Green
Event
What UML Modeling tools we use
today?
List of UML tools
http://en.wikipedia.org/wiki/List_of_UML_tools
ArgoUML: http://argouml.tigris.org/
Rational Rose (www.rational.com) by IBM
UML Studio 7.1 ( http://www.pragsoft.com/) by Pragsoft
Corporation: Capable of handling very large models (tens of
thousands of classes). Educational License US$ 125.00;
Freeware version.
TogetherSoft Control Center; TogetherSoft Solo (
http://www.borland.com/together/index.html) by Borland
Conclusion
UML is a standardized specification
language for object modeling
Several UML diagrams:
use-case diagram: a number of use cases (use case models the
interaction between actors and software)
Class diagram: a model of classes showing the static relationships
among them including association and generalization.
Sequence diagram: shows the way objects interact with one another
as messages are passed between them. Dynamic model
State diagram: shows states, events that cause transitions between
states. Another dynamic model reflecting the behavior of objects and
how they react to specific event
There are several UML tools available