0% found this document useful (0 votes)
15 views162 pages

Unified Modelling Language

Uploaded by

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

Unified Modelling Language

Uploaded by

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

Unified Modelling

Language

10/02/25 1
Object Modelling Using
UML

UML is a modelling language.
 Not a system design or
development methodology

Used to document object-oriented
analysis and design results.

Independent of any specific design
methodology.
2
UML Origin

OOD in late 1980s and early 1990s:
 Different software development houses
were using different notations.
 Methodologies were tied to notations.

UML developed in early 1990s:
 To standardize the large number of
object-oriented modelling notations
that existed.
3
UML Lineology

Based Principally on:
 OMT [Rumbaugh 1991]
 Booch’s methodology[Booch
1991]
 OOSE [Jacobson 1992]
 Odell’s methodology[Odell 1992]
 Shlaer and Mellor [Shlaer 1992]
4
Different Object Modeling
Techniques in UML

OMT

UML
Booch’s
OOSE
Methodology
5
UML as A Standard

Adopted by Object Management
Group (OMG) in 1997.

OMG is an association of industries

Promotes consensus notations and
techniques

UML also being used outside
software development area:
 Example car manufacturing 6
History of UML

UML 2.0
Industrialization

UML 1.1 Standardization

public
feedback
UML
UML0.9
0.9&&0.91
0.91
Unification

Unified method 0.8

Booch'93 OMT-2

Fragmentation7
Other methods Booch'91 OMT-1 OOSE
Developments to UML
UML 2.0 2003

UML continues
Applicatio
to develop: n to
embedded
 Refinements UML 1.X systems
 Making it
applicable to
new contexts UML 1.0 1997

8
Why are UML Models
Required?

Modelling is an abstraction
mechanism:
 Capture only important aspects and
ignores the rest.
 Different models result when different
aspects are ignored.
 An effective mechanism to handle
complexity.

UML is a graphical modelling tool 9
Modeling a House

10
UML Diagrams

Nine diagrams in UML1.x :
 Used to capture 5 different views of
a system.

Views:
 Provide different perspectives of a
software system.

Diagrams can be refined to get the
actual implementation of a system. 11
UML Model Views

Views of a system:
 User’s view
 Structural view
 Behavioral view
 Implementation view
 Environmental view 12
Diagrams and views in UML

Behavioural View
Structural View - Sequence Diagram
- Class Diagram - Collaboration Diagram
- Object Diagram - State-chart Diagram
- Activity Diagram
User’s View
-Use Case
Diagram

Implementation View Environmental View


- Component Diagram - Deployment Diagram

13
Example: Use Case Model
Super market
prize scheme
Register-
customer
Customer

Register-
sales

Select-
winners
Sales
Clerk Clerk

Manager
41
Use Case Description: Super
Market
 U1: register-customer: Using this use case, the
customer can register himself by providing the
necessary details.

 Scenario 1: Mainline sequence


1. Customer: select register customer option
2. System: display prompt to enter name, address,
and telephone number.
3. Customer: enter the necessary values
4: System: display the generated id and the message
that the customer has successfully been registered.

42
Use Case Description: Super
Market
Scenario 2: At step 4 of mainline sequence
4 : System: displays the message that the customer
has already registered.

Scenario 3: At step 4 of mainline sequence


4: System: displays message that some input
information have not been entered. The system
displays a prompt to enter the missing values.

43
Factoring Use Cases

Two main reasons for factoring:
 Complex use cases need to be
factored into simpler use cases
 To represent common behavior across
different use cases

Three ways of factoring:
 Generalization
 Include
 Extend 52
Generalization

One use case that is similar to another, but
does something slightly differently orparent
something more.

The child use case inherits the
child
behavior of the parent use case.
 The child may add to or override some of
the behavior of its parent.

53
Generalization Example 1

Registrati
on

Under- Graduate
graduate registration
registration 54
Factoring Use Cases Using
Generalization

Pay membership fee

Pay through credit card Pay through library pay card

55
Include

When you have a piece of behavior
that is similar across many use
cases
 Break this out as a separate use-case
and let the other ones “include” it


Examples of use case include
 Validate user interaction
 Check for proper authorization 56
Factoring Use Cases using Include

<<include>> Common
Base use case
use case

Base use case 2 Base use case 1

<<include>> <<include>>

<<include>> <<include>>

Common use case 1 Common use case 2


Common use case

57
Dependency in Use Cases

Normally, use cases are independent of
each other

Implicit dependencies may exist

Example: In Library Automation System,
issue-book/renew-book and reserve-book
are independent use cases.
 But in actual implementation of renew-
book--- A check is made to see if any book
has been reserved using reserve-book. 58
Example of Factoring Use
Cases Using Includes

Issue Book Renew Book

<<include>>
<<include>>

Check Reservation
59
Video Store Information System

Video Store Information System supports the
following business functions:
 Recording information about videos the store owns

This database is searchable by staff and all customers
 Information about a customer’s borrowed videos

Access by staff and also the customer. It involves video
database searching.
 Staff can record video rentals and returns by customers.
It involves video database searching.
 Staff can maintain customer, video and staff
information.
 Managers of the store can generate various reports.
60
Example
Video Store Information System

Rent/Return
Videos
«include» Customer
Staff

Search for
Videos
Maintain
Customers
«include»

Maintain
Videos

Manager Generate
Reports

61
Factoring Use Cases Using
Extends

Base <<extends>> Common


use case use case

63
Factoring Use Cases Using
Extends

Order <<extends>> Show


Item Catalog

64
Use Case Relationships

Order
Supply Product
Customer Data Arrange
<<include Payment
>> <<include
<<include >>
>>
Place Order
Cash Credit
Payment Payment
Sales
Person <<extends
>> Salesperson asks for
catalog

Request
Catalog
66
Example: Use Case Model for Course Management
Software

At the beginning of each semester,
 Each professor shall register the courses that he is going to
teach.

A student can select up to four-course offerings.
 During registration a students can request a course catalogue
showing course offerings for the semester.
 Information about each course such as professor, department
and prerequisites would be displayed.
 The registration system sends information to the billing
system so the students can be billed for the semester.

For each semester, there is a period of time during
which dropping of courses is permitted.

Professors must be able to access the system to see
which students signed up for each of their course
offerings.
67
Exercise 2: Answer
Course Management
Software
Register
offering

See Course
List
Professor Show
registration
<<Extends>
> <<External>
{ reg courses
< 5 courses} >
Register
{i course Billing
ft
od
ay System
<s
Student et
da
te
}
Drop
Course

Calendar
68
Factoring: Organization of Use
cases
use case
use case 11 use case 3 External users

use case 2

Hierarchical use case 3.1 use case 3.3


Organization of Subsystems
Use Cases use case 3. 2

use case 1 use case 3

Methods
use case 2
69
Too many use
cases at any
level should be
avoided!

70
Use Case Packaging

Accounts

Print
Query balance
Balance sheet

Receive Make
grant payments

Package the related uses cases so that at be


6-7 packages present at the top level diagra
71
Use-Case Model using
Packaging

72
Exercise: Home Assignment System - Use Case
Model

HAS will be used by the instructor to:
 Distribute the homework assignments,
 Review the students’ solutions,
 Distribute suggested solution,
 Assign grade to each assignment.

Students can:
 Download assignments
 Submit assignment solutions

System:
 Automatically reminds the students a day before an
assignment is due.
73
Quiz: Solution 1 (Inferior)
Remind
Student

Calendar Distribute Get


Assignments Assignment

Post Submit
<<Extends>>
Solutions Assignment

Student
Distribute Get
Grade Solution
Instructor

Get Grade
74
Quiz: Alternate (Better)
Solution

Distribute
Assignments

Post
Solutions

Student
Distribute
Grade
Instructor
Submit
Assignment

Remind
Student
Calendar
75
Class Diagrams

76
Class Diagram: Already
Discussed!!

Describes static structure of a
system

Main constituents are classes and
their relationships:
 Generalization
 Aggregation
 Association
 Various kinds of dependencies 77
Class Diagram

Classes:
 Entities with common features, i.e.
attributes and operations.
 Represented as solid outline rectangle with
compartments.
 Compartments for name, attributes, and
operations.
 Attribute and operation compartments are
optional depending on the purpose of a
diagram. 78
UML Class Representation
LibraryMember LibraryMember LibraryMembe

Member Name issueBook( );


Membership Number findPendingBooks( );
Address findOverdueBooks( );
Phone Number
returnBook( );
E-Mail Address findMembershipDetails( );
Membership Admission Date
Membership Expiry Date
Books Issued

issueBook( );
findPendingBooks( );
findOverdueBooks( );
returnBook( );
findMembershipDetails( );

79
Different representations of the LibraryMember class
Class Diagram

Attributes:
 Multiplicity expression, type, initialization
 e.g., sensorStatusid[10]: Int = 0

Operation
 Abstract operations are written in italics
 Parameter kind: in / out / inout
 Return type(….():type)

80
Visibility
of Attributes and Operations
Visibility Symbol Accessible To
Public + All objects within your system.

Protected # Instances of the implementing class and its


subclasses.

Private - Instances of the implementing class.

81
Summary of Relationships
Between Classes

Association
 Permanent, structural, “has a”
OR
 Solid line (arrowhead optional)

Aggregation
 Permanent, structural, a whole created from parts
 Solid line with diamond from whole

Dependency
 Temporary, “uses a”
 Dotted line with arrowhead

Generalization
 Inheritance, “is a”
 Solid line with open (triangular) arrowhead

Constraints
 Annotate class with {…..}
82
Multiplicity

Denotes the minimum number..
maximum number of instances
Exactly one 1
Zero or more 0..* or 0..m
One or more 1..* or 1..m
Zero or one 0..1
Specified range2..4
Multiple, disjoint ranges 1..3, 5
83
Object(Instance) Diagram
(LibraryMember)

Mritunjay (LibraryMember)
(LibraryMember)
B10028
C-108, Laksmikant Hall Mritunjay
1119 B10028
Mrituj@cse C-108, Laksmikant Hall
25-02-04 1119
25-03-06 Mrituj@cse
NIL 25-02-04
25-03-06
issueBook( ); NIL
findPendingBooks( );
findOverdueBooks( );
returnBook( );
findMembershipDetails( );

Different representations of the LibraryMember object


85
Example 1: University
Courses

Some instructors are professors, while
others have job title adjunct

Departments offer many courses, but a
course may be offered by >1 department

Courses are taught by instructors, who
may teach up to three courses

Instructors are assigned to one (or more)
departments

One instructor also serves a department
chair
G-86 2/14/05 86
Class Diagram for Univ.
Courses
chairs
0..1

Department 1
assigned to 1..*
1..*

1..*
Instructor

1
offers
teaches
1..* 0..3

Course Adjunct Professor

G-87 2/14/05 87
Deriving Class Diagram from
Use Cases and Scenarios

Analyze the text in the use-case
descriptions and scenarios

89
Guidelines for Analyzing Use Cases

A common or improper noun implies a class e.g.
Book

A proper noun implies an object (instance of a class):
CSE Dept, OOSD, etsc.

An adjective implies an attribute e.g. price of book

A “doing” verb implies an operation
 Can also imply a relationship e.g. student issues Book

A “having” verb implies an aggregation relationship

A predicate or descriptive verb phrase elaborates an
operation e.g. ISBN numbers are integers

An adverb implies an attribute of an operation e.g.
fast loading of image…
90
Exercise: Problem Report
Tool

A CASE tool for storing and tracking
problem reports
 Each report contains a problem description
and a status
 Each problem can be assigned to someone
 Problem reports are made on one of the
“artifacts” of a project
 Employees are assigned to a project
 A manager may add new artifacts and
assign problem reports to team members
G-94 2/14/05 94
Class Diagram for Prob.
Rep. Tool

G-95 2/14/05 95
Exercise

Develop UML Class diagram for a software that we have
been assigned to develop to manage a library.

Each member has a name, date of birth, address, phone
number and email

Each journal has a name, the ISBN code, the subject
areas, the shelf where it is located and the editor. Each
editor has a name and a nationality.

A journal may cover issues in several subject areas. It is
important to store the order of appearance of areas, since
these indicate their relative importance for the journal.

It is important to keep track of the date on which each
journal has been borrowed, returned, disappeared, and
the user carrying out the operation.
96
AreaOrder
-orderOfApperarance

1..* 1..*
Editor publishes Journal Area
- Addressed in
-editorName journalNam -areaName
-nationality 1 0..* 1 -areaDetails
e
-ISBN
-shelf
has

0..* Member
Operation 0..* 1 -userName
performs
-address
-date -birthDate
-operationType
-phone
-email
97
Elevator System

98
Identify Classes and Relations

Controller program for an elevator is to be developed.

Each elevator has a set of m buttons, one for each floor.
 These illuminate when pressed and cause the elevator to visit the
corresponding floor.
 The illumination is canceled when the elevator reaches the
corresponding floor.

Each floor, except the first floor and top floor has two
buttons:
 One to request and up-elevator and one to request a down-
elevator.
 These buttons illuminate when pressed. The illumination is
canceled when an elevator visits the floor. The door opens as
soon as it stops at a floor.

When an elevator has no requests, it remains at its current
floor with its doors closed.
99
Elevator Elevator_Control control Door
control
ler

*
Button

Elevator_Butt Floor_Butt
on on

100
Class Diagram: Problem
Draw a class diagram using the UML syntax
to represent the fact that an orderRegister
consists of many orders. Each order consists
of up to ten order items. Each order item
contains the name of the item, its quantity
and the date by which it is required. Each
order item is described by an item order
specification object having details of an
order item such as its unit price, name and
address of the manufacturer , and the
warranty period and terms of warranty.
101
Class Diagram: Problem
Draw a class diagram using the UML syntax
to represent the following aspects
concerning a library. An issuable can either
be a book or a CD. Books can be either
reference books or text books. The details of
various issuables are maintained in a
register called the issuable register. The
library has many members whose details are
maintained in a member register . A member
can issue upto 10 text books for a month. A
member can also issue two CDs for a week.
102
Class Diagram: Problem
Draw a class diagram using the UML syntax
to represent the fact that the fleet of
vehicles at a travel agency consists of
vehicles of the types Tata Indica, Maruti van,
and Mahindra Xylo. The regular customers of
the travel agency can rent any vehicle they
want. The details of the customers such as
the name, address, and phone number are
maintained by the agency

103
Class Diagram: Problem
Draw a class diagram using the UML syntax
to represent the following. An engineering
college offers B.Tech degrees in three
branches— Electronics, Electrical, and
Computer science and engineering. Each
branch can admit 30 students each year .
For a student to complete, B.Tech degree
he/she has to clear all the 30 core courses
and at least 10 of the elective courses.

104
Interaction
Diagrams

105
Interaction Diagram

Can model the way a group of objects
collaborate to realize some
behaviour.

How many interaction diagrams to draw?
 Typically each interaction diagram realizes
behaviour of a single use case
 Draw one sequence diagram for each
use case.
106
Interaction Diagrams

Kinds:
 Sequence and Collaboration diagrams.

Sequence and Collaboration diagrams are
equivalent:
 Portray different perspectives
 These diagrams play a very important role
in the design process.

107
A First Look at Sequence
Diagrams

Captures how objects interact with
each other:
 To realize some behavior.

Emphasizes time ordering of
messages.

Can model:
 Simple sequential flow, branching,
iteration, recursion, and concurrency.
108 108
Sequence Diagram

Shows interaction among objects as a two-
dimensional chart

Objects are shown as boxes at top

If object created during execution:
 Then shown at appropriate place in time line

Object existence is shown as dashed lines
(lifeline)

Object activeness, shown as a rectangle on
lifeline
109
Sequence Diagram Cont…


Messages are shown as arrows.

Each message labelled with
corresponding message name.

Each message can be labelled with
some control information.

Two types of control information:
 condition ([])
 iteration (*) 110
Sequence Diagram Cont…


an Order Line

An object in a sequence diagram is rendered


as a box with a dashed line descending from it.
The line is called the object lifeline, and it
represents the existence of an object over a
period of time.

111
Sequence Diagram Cont…


an Order Line a Stock Item
Messages are rendered as horizontal
arrows being passed from object to
check()
object as time advances down the
[check = “true”]
remove() object lifelines.
Conditions ( such as
[check = “true”] ) indicate when a
message gets passed.

112
Sequence Diagram Cont…

an Order Line a Stock Item

check()

[check = “true”]
Notice that the bottom arrow is
remove() different. The arrow head is not solid,
and there is no accompanying message.

This arrow indicates a return from a


previous message, not a new message.

113
Sequence Diagram Cont…

an Order a Order Line

* prepare()
An iteration marker, such as * (as
shown), or *[i = 1..n] , indicates
that a message will be repeated as
indicated.
marker

114
Sequence Diagram Cont…

an Order Entry
an Order an Order Line a Stock Item
window
prepare()
Condition
* prepare()
Object
check()

Message [check = “true”]


remove() needsToReorder()
Iteration
Self-Delegation
Return

new
A Reorder
Item

A Delivery
Item

Creation
115
Gist of Syntax

iteration marker *[for all objects]

[condition]
 the message is sent only if the
condition is true

self-delegation
 a message that an object sends to itself

116
Control logic in Interaction Diagrams

Conditional Message
 [ variable = value ] message()
 Message is sent only if clause evaluates to
true

Iteration (Looping)
 * [ i := 1..N ] message()
 “*” is required; [ ... ] clause is optional
 The message is sent many times to
possibly multiple receiver objects.
117
Elements of A Sequence
Diagram
X-Axis (objects)

member: book:Book :Book


LibraryMember Copy

borrow(book) Life Line


Object
ok = canBorrow()
Y-Axis

message

Activatio
[ok] borrow(member) n box
setTaken(member)

condition

118 118
Message Arrows for
 Communication
Message arrows represent communications
between two objects in a sequence diagram
 Synchronous message :

Sending object suspends action and waits for the
response to the message

(filled head)
 Asynchronous message:

Sending object continues with its operations without
waiting for the response

(open head)
 A return of control from the synchronous
message
 A creation of a new entity
119
An Example of A Sequence Diagram
:Library
:Library
:Library Book :Library
Book :Book
Boundary Renewal Member
Register
Controller

renewBook find MemberBorrowing


displayBorrowing
selectBooks bookSelected
* find
[reserved]
[reserved] apology
update
apology

confir
m

confirm
updateMemberBorrowing

120
Sequence Diagram for the renew book use case

Exercise: Draw a sequence diagram to
represent the following interactions between a
video store clerk and objects in a video rental
system. The scenario name is rent video:
 Clerk creates new a Rental object named
aRental.The message includes arguments for
memberID and videoID.
 aRental sends add MemberToRental message
to Member object based on memberID, named
aMember, which returns member details.
 aRental sends rentVideo message to a Video
object based on the videoID, named aVideo,
which returns video details.
 aRental returns all rental details to the actor.
121
Video
Clerk aMembe aVideo
r
aRental
create(memberID,videoID
)
addMembertoRental(
)

Member details

rentVideo()

Video details

Rentaldetails

122
Diagrams and views in UML

Behavioural View
Structural View - Sequence Diagram
- Class Diagram - Collaboration Diagram
- Object Diagram - State-chart Diagram
- Activity Diagram
User’s View
-Use Case
Diagram

Implementation View Environmental View


- Component Diagram - Deployment Diagram

125
Collaboration Diagram

Known as Communication Diagram in
UML 2

Shows both structural and behavioural
aspects:
 Objects are collaborator, shown as boxes along
with links among them indicating association
3 : notify()
4 : update() s1 :StockQuote
Subscriber

 Messages between objects 1 : attach(s1)


6 : getState()
p : Stock
shown as labelled arrow QuotePublisher
5 : update()

placed near links 2 : attach(s2) s2 :StockQuote


7 : getState() Subscriber


Messages are prefixed with sequence
numbers to show relative sequencing 126
Another Example Collaboration
Diagram
6: * find
:Library
Book :Book
[reserved] Register
9: update
8: apology 5: book 10:
Selected confirm

1: :Library [reserved]
:Library renewBook Book 7: apology
Boundary 3: display Renewal
Borrowing Controller

4: selectBooks
2: findMemberBorrowing

12: confirm
:Library
Member
11: updateMemberBorrowing

Collaboration Diagram for the renew book use case


127
An Example of A Sequence Diagram
:Library
:Library
:Library Book :Library
Book :Book
Boundary Renewal Member
Register
Controller

renewBook find MemberBorrowing


displayBorrowing
selectBooks bookSelected
* find
[reserved]
[reserved] apology
update
apology

confir
m

confirm
updateMemberBorrowing

128
Sequence Diagram for the renew book use case
Activity Diagram

129
Activity Diagram

In its basic form, an activity diagram is
 a simple and intuitive illustration of what
happens in a workflow, what activities can
be done in parallel, and
 whether there are alternative paths
through the workflow.

130
Activity Diagram

Not present in earlier modelling techniques:
 Possibly based on event diagram of Odell [1992]

Often used to represent various activities or chunks
of processing and their sequence of activation
 May not correspond to methods

An activity is a state with an internal action
and has one or more outgoing transitions, e.g.
fillOrder.

Vaguely similar to a flowchart

131
Activity diagram Example
[order reject]

Receive Fill Close


Ship
Order Order Order
Order
[order
accepted]

Send
Invoice Make Accept
Invoice Payment Payment

133
Activity Diagram

Normally employed in business process
modelling.
 Spans one or more use cases

Carried out during requirements
analysis and specification stage.

Useful in developing interaction
diagrams and test cases.
134
Activity Diagram
(continued)

Transitions in an activity diagram do
not have labels:
 They indicate the completion of an
action

An activity diagram may describe a
use case, an operation or a message
 Purpose: to describe details that may be
useful in implementation.
135
Activity Diagram Elements

Initial node

Activity final node

Action

Flow/edge

Fork

Join

Decision

Merge

Synch
136
Basic Elements—Action

A rounded rectangle represents an action.

The fundamental unit for execution or
behavior.
 Represents some transformations or
processing in the modeled system
 Example: Customer Makes Payment

Make
Payment
137
Controlling Steps
 Inherited from state machines

 Initial state

 Final state

 Fork and join

138
Basic Elements--Initial
state

The filled circle is the initial state:
 The staring point of the diagram.

First Action
To DO

139
Basic Elements—Final
node

The filled circle with a border as
the ending point.
An activity diagram can have
zero or more activity final
nodes
First Action
To DO

140
Fork

Denotes the beginning of parallel
actions.
Verify Order
Products Are
In Stock

Receive
Order
Verify
Customer Has
Available
Credit
141
Join

Models Synch with several flows entering
and one leaving.

All incoming flows must reach it before
processing may continue.
 This denotes the end of parallel processing.
Verify Order
Products Are In
Stock

Accept Order

Verify Customer
Has Available
Credit

142

Decision point and merge
( ):
 Inherited from state machines.
Calculate [cost < 50] Charge
Cost Account

[cost >= 50]

Get
Authorization

143
Check-In in the Business Use-Case
Model of Airport Check-in

145
Activity Diagram vs Flow
Chart

Can represent parallel activity and
synchronization aspects

Swim lanes can be used:
 To group activities based on who is
performing them

Example: Academic department vs.
Hostel

147
Customer Sales Stockroom

Request
service

Take
Order
Pay
Fill
Order

Deliver
Collect order
order

C-S 546 148 148


Another Example Activity
Diagram: student admission
Academic Section
process
Accounts Section Hostel Office Hospital Department

check
student
records
receive
fees

allot create
hostel hospital
record
register
receive
in
fees
course
conduct
allot medical
room examination

issue
identity card 149
Quiz 1: Order Processing

The customer service Department receives order
and sends out invoice to the customer.
 It also passes on the order to the order processing
Department to process the order

If it is a rush order then the customer service
Department prepares for an overnight delivery by
express mail
 Otherwise it prepares to send by speed post.

As soon as the payment is received by the finance
Department from the customer:
 The order is dispatched by the customer service
Department and it also closes the order.
158
Customer services
department
Order Receive Finance
Processing order department
department

Fill order Send


invoice

[rush order] [Else]

Overnigh Ordinary
delivery
t delivery Receive
payment

Quiz 1: Close
order
Answer 159
State Chart
Diagram

160
State Chart Diagram


Used to model how the state of
an object changes in its life time

Good at describing how the
behaviour of an object changes
across several use case
executions.
161
State Machine
Diagram

10/02/25 162
Stateless vs. Stateful Objects

State-independent (modeless):
 Type of objects that always respond the same way
to an event.


State-dependent (modal):
 Type of objects that react differently to events
depending on its state or mode.

Use state machine diagrams for modeling


state-dependent objects with complex
behavior.
165
Basic State Machine Diagram

Graphical representation of
automata behavior…
on

Lamp On

on

off
off
Lamp Off
166
State Chart Diagram Cont…


State chart avoids two problems of FSM:
 State explosion
 Lack of support for representing
concurrency

A hierarchical state model:
 Can have composite states --- OR and
AND states.

167
Features of Statecharts

Two major features are
introduced :
S1
 nested states S2
 concurrent states
Nested State Diagrams

Many other features have also
been added:
 History state
 broadcast messages
 actions on state entry, exit
 …
Concurrent State Diagrams
168
Nested State Diagrams

Hierarchical organization
is a classic way to control
complexity:
 of programs superstate

 of documentation
 of objects
 …

Why not state diagrams?
 superstates
substates
 substates 169
State Chart Diagram
Cont…

Elements of state chart diagram

Initial State: A filled circle

Final State: A filled circle inside a larger
circle

State: Rectangle with rounded corners

Transitions: Arrow between states, also
boolean logic condition (guard)

170
Basic UML State Diagram Syntax

A state is drawn with a
round box, with three
compartments for: Name sometimes
 name state variables
left out when
empty
 state variables actions
 actions performed

A transition is drawn
with a labeled arrow,
 event causing the
transaction
 guard condition AnEvent [guard] / SomeAction
 Action to perform
171
Example of A State Chart
Diagram
order received
Unprocessed
Order
[reject] checked [accept] checked

Rejected Accepted
Order Order
[some items available]
[some items not processed / deliver
available] processed

[all items
Pending available] Fulfilled
Order newsupply Order

Example: State chart diagram for an order object 174


Exercise

Draw the state chart diagram of an elevator.

The elevator is by default at the ground floor.

It moves up when an up button is pressed and halts
when the required floor is reached.

When a button at a lower floor is pressed:
 It moves down and halts when the required floor is
reached.

When it is inactive at a floor for more than 10
minutes:
 It moves down to the ground floor.
176
Elevator: State Machine Representation

On Ground up floor Moving


Floor Up
arrive
at floor
arrive up floor
Moving to at floor
Ground Floor

arrive at
Moving floor Idle
Down down floor

time-out 177
Improvements
in UML 2.0

10/02/25 178
Diagrams and views in UML

Behavioural View
Structural View - Sequence Diagram
- Class Diagram - Collaboration Diagram
- Object Diagram - State-chart Diagram
- Activity Diagram
User’s View
-Use Case
Diagram

Implementation View Environmental View


- Component Diagram - Deployment Diagram

179
Package Diagrams
• A package is a grouping
of several classes:
– Java packages are a good Order Capture Mailing List
AWT
example UI UI
• Package diagrams show
module dependencies.
• Useful for large projects
Order Capture Mailing List
with multiple binary files Application Application

Dependency
Common
{global}
Oracle Quantity
Interface Money Domain
DateRange

Sybase
Database Orders Customers
Interface
Interface
{abstract}
180
Component Diagram

What is a component?
 A piece of software that can be
independently purchased and
upgraded, and can integrate
seamlessly into customers’
existing software.
Librarian
Librarian

UML 1 notation UML 2 notation

181
Component Diagram

Captures physical structure of the
implementation in terms of various
components of the system.

Purpose:

 Organize source code



To be able to construct an executable release

 Specify dependencies

Among different components
182
Component Diagram

Captures the physical structure of the
implementation (code components)
UML 1.X
Notatio
n
dependency

Components:
• Executables
• Library
• Table
• File
• Document

183
Component Diagram:
Example

Library

UI Librarian DB

Ports can be named,


such as the Security and
Data ports
Database
A package diagram can be used to provide a
high-level view of each component in terms 185
of different classes it contains
Diagrams and views in UML

Behavioural View
Structural View - Sequence Diagram
- Class Diagram - Collaboration Diagram
- Object Diagram - State-chart Diagram
- Activity Diagram
User’s View
-Use Case
Diagram

Implementation View Environmental View


- Component Diagram - Deployment Diagram

186
Deployment Diagram

The deployment diagram shows:
 How a software system will be physically
deployed in the hardware environment.

Its main purpose is:
 Show which component will execute on
which hardware component and
 How they will communicate with each
other.

Since the diagram models the runtime
architecture of an appln.
 Diagram can be very useful to system's 187

operation staff
Deployment Diagram

Node:
 Something that can host an artifact.
 A node represents a physical machine.
 To model a node, draw a three-dimensional cube
with the name of the node at the top.
 Physical nodes should be labeled with the
stereotype device

Artifact:
 Files, assemblies, DLL, or scripts
 An artifact is usually a component
188
Deployment Diagram

Captures the topology of a system’s
hardware

A piece of
hardware

189
New Notations in UML 2

UML 2 was a major revision of the
UML standard.

Several new notions and concepts
have been introduced.
 Based on feed back from practitioners
 Can now be applied meaningfully to
many classes of problems such as
embedded and telecommunication
software development.
191
UML 2 Diagrams

UML now defines thirteen types of
diagrams, divided into three
categories:
 Six diagrams represent static application
structure
 Three represent different aspects of
dynamic behavior
 Four represent Interaction among your 192
192
UML Structural Diagrams

Class Diagram

Object Diagram

Component Diagram

Composite Structure Diagram

Package Diagram

Deployment Diagram
193
193
UML Behavior diagrams

Use Case Diagram

Activity Diagram

State machine Diagram

194
194
UML Model Interaction
Diagrams

Sequence Diagram

Communication Diagram

Timing diagram

Interaction Overview
Diagram 195
195
UML 2.0 Highlight of Changes
list is not comprehensive

Introduced new concept of Ports

Composite Structure Classes & Diagrams

Class Diagrams – the least changed

Collaboration Diagram – renamed to
Communication Diagram

Sequence Diagram – nesting options

New diagram introduced – Timing Diagram
196
196
UML 2.0 Highlight of Changes
list is not comprehensive


Activity Diagrams have the greatest
number of changes of any of the
UML diagrams

Use Case Diagrams – added
multiplicity and changes with
extension points.

Package Diagram now an official 197
197

Combined Fragments in
sequence diagrams


Composite Structure Diagram

198
198
Combined Fragments in
sequence diagrams
Anatomy:
Appears over an area of a sequence diagram to
make certain control and logic aspects visually
clear .
Divides a sequence diagram into a number of areas
or fragments that have different behaviour
Consists of many fragments and an operator shown
at the top left corner .
Each fragment can be associated with a guard (a
Boolean expression).
199
199
Combined Fragments in
sequence diagrams..


Anatomy of a combined fragment

200
200
Combined Fragments in
sequence diagrams..
Fragment:
Represented by a box, and encloses a portion of
the interactions within a sequence diagram.
Each fragment is also known as an interaction
operand.
An interaction operand may contain an optional
guard condition, which is also called an
interaction constraint.
The behaviour specified in an interaction operand
is executed only if its guard condition evaluates
to true. 201
201
Combined Fragments in
sequence diagrams..

A combined fragment is associated with one
operator called interaction operator that is shown
at the top left corner of the fragment.

The operator indicates the type of fragment. The
type of logic operator along with the guards in the
fragment defines the behaviour of the combined
fragment.

A combined fragment can also contain nested
combined fragments that represent more complex
structures that affect the flow of messages.
202
202
Combined Fragments in
sequence diagrams..

Some imp. operators
loop – repeat interaction fragment
alt – selection
par – concurrent (parallel) regions
opt – optional “exemplar”
Region - critical region – only one thread can execute

203
203
Combined Fragments in
sequence diagrams..

An example sequence diagram showing a combined fragment

204
204
Combined Fragments in
sequence diagrams..

205
205
Ports

A Port is a named interface on a component:
 It defines a set of operations and events that are provided by a
component or that are required from its environment.

The port has:
 A name.
 An interface specifying the signals that can be received.
 An interface specifying the signals that can be sent.

Two types of ports:
 Connected to internal communication channels (by default).
 Connected to the state machine for the class instance (a behaviour port).

In interface
206
Out interface
A behaviour port

Combined Fragments in
sequence diagrams


Composite Structure Diagram

207
207
Composite Structure
Diagram

The composite structure diagram
lets you define how a class is
defined by

 a further structure of classes and


 the communication paths between
these parts.

208
Composite Structure
Diagram
Some new core constructs such as parts, ports
and connectors:.
Part: The concept of parts makes possible the
description of the internal structure of a class.
Port: The concept of a port makes it possible
to describe connection points formally. These
are addressable, which means that signals can
be sent to them.
Connector: Connectors can be used to specify
the communication links between two or more
parts.
209
Syntax of Composite
Structure Diagram

210
Composite Structure Diagram

Lets you capture how a class is defined by a
further structure of classes
 and the communication paths between these
parts.

215
Tools Supporting UML 2.0

PlantUML

Open Source ArgoUML

ARTiSAN's Real-time Studio

Borland Together 2006 for Eclipse

Computas' Metis with UML 2.0 Template

Embarcadero Describe

IBM Rational Software Architect and Modeler

I-Logix Rhapsody

MetaMatrix MetaBase Modeler

Mia Software Model-in-Action

No Magic's MagicDraw UML
216
Tools Supporting UML 2.0
continued……..

OMONDO EclipseUML Studio

Pathfinder Solutions' PathMATE 5.2

Open Source StarUML sponsored by Plastic Software

Sparx Systems Enterprise Architect

Sun Microsystems' Java Studio Enterprise

Pattern Weaver Ver. 2.0 Technologic Arts Inc.
(Japanese)

Telelogic's TAU Developer and TAU Architect

Gentleware's Poseidon for UML

Visual Paradigm's Smart Development Environment
tool series

217
Review Questions
Choose the correct option:
The packing of data and functions into a
single unit in a program is known as:
(i) polymorphism
(ii) abstraction
(iii) encapsulation
(iv) inheritance
218
Review Questions
Consider the statement—“An employee is
either a worker or a manager .” Assuming
that Employee and Manager to be two
classes, what can be said about the
relationship between these two classes?

(i) Association
(ii) Generalisation-specialisation
(iii) Containment
(iv) Polymorphism
219
Review Questions
Which one of the following can be said
about an abstract data type (ADT):
(i) Same as an abstract class
(ii) A data type that cannot be instantiated
(iii) A data type that can only be used
through the operations defined on it
(iv) Same as a collection of data items
220
Review Questions
Consider the sentence: A book has one or
more pages. Which of the following
concepts characterise it best ?
(i) Inheritance
ii) Specialisation
(iii) Association
(iv) Composition
221
Review Questions
A sequence diagram is:
(i) A time-line illustrating a typical sequence of
calls between object function members
(ii) A call tree illustrating all possible sequences
of calls between class function members
(iii) A time-line illustrating the changes in
inheritance and instantiation relationships
between classes and objects over time
(iv) A tree illustrating inheritance and
relationships between classes

222
Review Questions
State TRUE o r FALSE of the following. Support
your answer with proper reasoning:
(a) An object oriented design cannot be
implemented using a procedural programming
language.
(b) Any language directly supporting abstract
data types (ADTs) can be called as an object-
oriented language.
(f ) Inheritance feature of the object oriented
paradigm helps in code reuse.

223
Review Questions
State TRUE o r FALSE of the following. Support your
answer with proper reasoning:
(g) Inheritance relationship between two classes can
be considered as a generalisation- specialisation
relationship.
(h) Object embedding (i.e., composite objects) can
be used to realise inheritance relationship.
(i) Aggregation relationship between classes is
antisymmetric.
(j) The aggregation relationship can be recursively
defined, i.e an object can contain instances of itself.

224
Review Questions
State TRUE o r FALSE of the following. Support your
answer with proper reasoning:
(k) State chart diagrams in UML are normally used
to model how some behaviour of a system is
realised through the co-operative actions of several
objects.
(l) Multiple inheritance is the feature by which many
subclasses can inherit features of one base class.
(m) Class diagrams developed using UML can serve
as the functional specification of a system.
(n) An important advantage of polymorphism is
facilitation of reuse.
225
Review Questions
State TRUE o r FALSE of the following. Support
your answer with proper reasoning:
(o) A static object-oriented model should capture
attributes and methods of classes and in what
order the different methods invoke each other.
(p) In a UML class diagram, the aggregation
relationship defines an equivalence relationship
on objects.
(r) The aggregation relationship can be
considered to be a special type of association
relationship.
226
Review Questions
State TRUE o r FALSE of the following. Support
your answer with proper reasoning:
(u) Normally, you use one interaction diagram
per class to represent how the behaviour of an
object of the class changes over its life time.
(v) It is possible that more than one methods in
a class implement the same operation.
(y) From the UML sequence diagram for a use
case, it would be possible to infer the various
scenarios in the use case.

227
End

229

You might also like