Professional Documents
Culture Documents
Islamabad, Pakistan 1
OBJECT ORIENTED
ANALYSIS AND DESIGN
Instructor : Muhammad Ahmed
Mr Atif Jilani
FALL 2010 Lecture : OO Design
Date : 29th October 2010
Contents
2
DESIGN PHASE
OOAD
Fall 2010
Design Phase
4
Real Usecases
Design Class
Use Case Diagrams
Model
Deployment
Diagrams
4
UPC A Quantity E
B F
Actor Action Price
Desc
Total C Balance G
arrives at the POST checkout with Enter Item End Sale Make Payment
items to purchase. H I J
People new to UML tend to think that the important diagram is the static-
view class diagram, but in fact, most of the challenging, interesting, useful
design work happens while drawing the UML dynamic-view interaction
diagrams.
It's during dynamic object modeling (such as drawing sequence diagrams)
that "the rubber hits the road“
in terms of really thinking through the exact details of what objects need to
exist
how they collaborate via messages and methods
During dynamic modeling that we apply responsibility-driven design and
the GRASP principles.
Other dynamic tools in the UML kit
state machine diagrams
activity diagrams
10
11
12
DYNAMIC OBJECT
MODELLING
OOAD UML Interaction Diagrams
Fall 2010 Chapter 15 Craig Larman
Dynamic Object Modeling
14
14
attributes:
receiver object
attributes:
operations:
operations:
message:
[sender, return value(s)]
16
17
18
1: message2()
message1() 2: message3()
:ClassAInstance :ClassBInstance
Sequence Diagrams
:ClassAInstance :ClassBInstance
message1()
message2()
message3()
19
20
21
22
BASIC
COMMUNICATION
DIAGRAM NOTATION
OOAD
Fall 2010
Illustrating Classes and
24 Instances
For any kind of UML element (class, actor, …) an
instance uses the same graphic symbol as the type,
but the designator string is underlined.
24
A link is a connection path between two objects; it indicates some form of navigation and
visibility between the objects is possible.
More formally, a link is an instance of an association.
msg1()
link line
Note
Note that multiple messages and both ways, flow along the same single link.
There isn't one link line per message; all messages flow on the same line, which is like a road
allowing two-way message traffic.
25
Each message between objects is represented with a message expression and small
arrow indicating the direction of the message.
26
parameters
msg1()
1: addPayment(amount: Money)
:POST :Sale
27
msg1(
)
1: tot := total(): Integer
:POST :Sale
28
msg1()
1: addPayment(cashTendered)
:POST :Sale
standard UML
message syntax
29
iteration clause
recurrence values
msg1()
30
31
msg1()
1: create(cashier)
:POST :Sale
«new»
:Sale
"«new»" is optionally
allowed for emphasis
32
not numbered
2: msg5()
msg1() 1: msg2()
:ClassA :ClassB
legal numbering
:ClassC
33
first second
third
1.1: msg3()
2.1: msg5()
2: msg4() :ClassC
fourth fifth
2.2: msg6()
sixth
:ClassD
Exercise: Write down the codes for all methods shown in the diagram
34
msg1()
1.1: create()
:SalesLineItem
35
2: msg6()
36
Sale multiobject
sales : Sale
Messages to Multiobjects
msg1()
37
msg1()
2: addElement(sl) SalesLineItem
:SalesLineItem
msg1()
2: print()
:Sale sl: SalesLineItem
1: sl := get(key) SalesLineItem
:SalesLineItem
38
message to class
msg1()
1: d1 := today(): Date
:Sale Date
not underlined,
therefore a class
39
BASIC SEQUENCE
DIAGRAM NOTATION
OOAD
Fall 2010
Illustrating Participants with Lifeline Boxes
41
41
42
43
44
45
Frame
Operator Meaning
alt Alternative fragment for mutual exclusion conditional logic
expressed in the guards.
loop Loop fragment while guard is true. Can also write loop(n) to
indicate looping n times. There is discussion that the
specification will be enhanced to define a FOR loop, such as
loop (i, 1, 10)
opt Optional fragment that executes if guard is true.
par Parallel fragments that execute in parallel.
region Critical region within which only one thread can run.
46
:Payment
Authorize()
47
:Sale
The “destroy”
stereotyped message,
Create(cashTendered) with the large X and
:Payment short lifeline indicates
explicit object
... destruction
“destroy”
Object destruction
48
49
50
51