Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

X-Axis (objects) Elements of

A Sequence
member:
book:Book
:Book Diagram
LibraryMember Copy
Y-Axis (time)

borrow(book) Object

EL
Life Line
ok = canBorrow()
message

PT
Activation box
[ok] borrow(member)
setTaken(member)

N
condition

How do you show Mutually exclusive conditional messages?

1 1
Asynchronous Messages
:ActionListener :Inventory

addActionListener(self:ActionListener)

EL
Time

…continue operation…
The eventual

PT
response is
called a callback
actionPerformed(e: ActionEvent)

N
2
• Optionally indicated using a dashed arrow:
Return
Values
– Label indicates the return value.
v
– Don’t need when it is obvious what is being

EL
returned, e.g. getTotal()

PT
• Model a return value only when you need to
refer to it elsewhere:
N
– Example: A parameter passed to another message.

3
Summary of Kinds of Arrows

synchronous Method call (The sender losses control until


the receiver finishes handling the message)

EL
asynchronous
Flat flow of control(The sender does not

PT
expect a reply)

return Return
N
(Unblocks a synchronous send)

4
• Methods of a class are determined from the interaction
diagrams…
for every use case we develop one sequence diagram and for complex use cases wedraw
Method Population
multiple sequence diagram which are link together by an interaction over view diagram. in Classes from
:Registration :Registration Sequence Diagrams
form manager

EL
add course
RegistrationManager

PT
(joe, math 01)

addCourse(Student,Course)

N
5
Example Sequence Diagram: Borrow Book Use Case
member: :Book
book:Book
LibraryMember Copy

EL
borrow(book)
ok = canBorrow()

PT
[ok] borrow(member)
setTaken(member)
N
6
Object Creation
• An object may create another object ---represented using a
<<create>> message.

EL
:A

PT
:B
<<create>>

N
7
Object Destruction
• An object may destroy another object via a <<destroy>> message.
– An object may also destroy itself.
• But, how do you destroy an object in Java?
– Avoid modeling object destruction unless memory management is critical.

EL
:A :B

PT
<<destroy>>

N
8
Control Information Iteration
example
UML 1.x:
:CompoundShape :Shape

EL
draw()
*draw()

PT
N
9
Quiz: Write Code for class B
b

m1
<<create>>
:B

EL
flag=doA(this)
<<create>>

PT
doB(c) c:C

N
10
a:A
m1
<<create>>
:B
flag=doA(this)
<<create>>
c:C

EL
PT
N
11
Quiz: Ans
public class B {

int doA(A a) {

EL
int flag;
C c = new C();

PT
a.doB(c); …
return flag; }
} N
12
Due to the frames, it becomes easy to associate which use case it captures or represents

• A frame consists of: the interactions in which use case


order process

1) Diagram identifier
:client :order :inventory
2) Participating objects:
create

EL
• A dotted line that Locate item
extends for the time
period of the interaction

PT
3) Messages to
communicate among
the participants N Frames in a
Sequence Diagram

13
order Example
:StoreGUI :Cart :Inventory Frames in
Sequence
loop Diagrams
addItem here is part of the add item,
reserveItem it calls the reserve item on

EL
the inventory.And that
occurs again and again due to
the loop each time add item
and reserve item. But in

PT
UML1.x, we could not even do
this because if we write here
checkout star add item and star
reserved item,is it that first

confirmOrder
N processOrder

adjustInventory
all items are added to the
cart and then all the items
are reserved in
theinventory? No, that is not
the way we intended

14
sd sample Frame name Depicting a Frame
Graphically
:client :order :inventory
Interaction
Frame

EL
<<create>>

operator op1
Interaction

PT
Frame
Operation
Name: Interaction
(e.g. loop) Frame
Operand

N Locate item

15
op [guard 1] Interaction Frame Syntax
Guard 1 is true if condition, then do this interaction. If guard 2
Interaction 1 is true,then do this interaction guard n is true, then do this
interaction. So, that is more like a switch

EL
[guard n]
Interaction n

PT
• Divided into a set of interactions by dotted lines
N
• Interaction i is executed if guard i is true

16
Frame Frame
Operator Meaning Operators
Alt Alternative fragment for conditional logic
expressed in the guards

EL
Loop Loop fragment while guard is true. Can also
write loop(n) to indicate looping n times.

PT
Opt Optional fragment that executes if guard is
true
Par Parallel fragments that execute in parallel

Region N
Critical region within which only one thread can
run

17
:A :B Nesting of
Frames
We can nest frames, the
first one is opt, if colour is
opt [colour = red] red,then this behaviour or
this interaction is carried

EL
out.You calculate the
Loop(n) calculate method is B is called
the distribute method on the
B is called,if colour is red and
calculate

PT
this occurs for n times the
calculate and distribute is
called.
distribute
N
18
Code
:Employee :EmployeeDB Generation:
Example 1
Emp=getEmployee(empId)

EL
Public class EmployeeDB{

PT
public Employee getEmployee(String empId){

}
N
}

19
:ShapeFactory
Code
Generation:
makeSquare Example 2
<<create>>
:Square

EL
Public class ShapeFactory{

PT
public Shape makeSquare(){

}
N
return new Square(); }

20
Public class TreeMap{
:TreeMap :TreeNode private TreeNode t;
clear
<<destroy>> public void clear(){

EL
t=null;
}

PT
Exercise }
Write
Java Code
N
21
Collaboration
The sequence diagram is a behavioural diagram where is a collaboration or the communication diagram
represents both structural and behavioural aspects.
• Known as Communication Diagram in UML 2
Diagram
• Shows both structural and behavioural aspects: 3 : notify() 4 : update() s1 :StockQuote
Subscriber

– Objects are collaborators, shown as boxes 1 : attach(s1)

EL
p : Stock 6 : getState()
Quote
5 : update()

– Messages between objects shown as labelled arrow 2 : attach(s2) s2 :StockQuote


7 : getState() Subscriber

PT
placed near links

• Messages are prefixed with sequence numbers


to show relative sequencing
N
22
p : StockQuotePublisher s1 : StockQuoteSubscriber s2 : StockQuoteSubscriber Sequence vs
attach(s1)
communication
attach(s2) Procedure call, RMI, JDBC, … Diagrams
Observer
Time notify() design
pattern
update()

EL
{update < 1 minutes}
getState()
update()
getState()

PT
3 : notify() 4 : update()
s1 :StockQuoteSubscriber

p : StockQuotePublisher N
5 : update()

2 : attach(s2)
1 : attach(s1)
6 : getState()

s2 :StockQuoteSubscriber
7 : getState()

23
Collaboration :Book
6: * find
Diagram for the
renew book use :Library
9: update
:Library
:Library
Book
:Library
Book :Book
:Library

case
Boundary Renewal
Register Member
Controller
Book
[reserved] Register renewBook find MemberBorrowing

EL
displayBorrowing

8: apology 5: book 10: selectBooks


bookSelected

Selected confirm * find


[reserved]

1: renewBook :Library [reserved]

PT
[reserved] apology

:Library Book 7: apology apology


update

Boundary 3: display Renewal


Borrowing Controller confirm

2: findMemberBorrowing
4: selectBooks

12: confirm
N :Library
confirm
updateMemberBorrowing

updateMemberBorrowing
Member

24
Activity Diagram

EL
PT
N
25
• Not present in earlier modelling languages: Activity Diagram
– Possibly based on event diagram of Odell [1992]

• Activity diagram used to represent processing steps in a

EL
use case or a group of use cases (workflow) :
– Basic activities may or may not correspond to methods

PT
• An activity is a state with an internal action and has one
or more outgoing transitions, e.g. fillOrder.
N
• Vaguely similar to a flowchart...

26
• Normally employed in business process
Uses of Activity
Diagram
modelling.Spans one or more use cases
The initial activity model is developed during the requirements analysis where the developers try to understand the business process
that they are going to automate. And not only that,it helps to arrive at a proper design,

EL
• Carried out during requirements analysis and

PT
specification stage.
N
• Useful in developing use cases and test cases.

27
[order reject] Activity diagram
First Example
Receive Pack Ship Close
Order Order Order Order
[order

EL
accepted]

PT
Send
Invoice
Invoice NMake
Payment
Accept
Payment

28
• Initial node Activity Diagram Elements
• Activity final node
• Action
• Action Flow/Object flow/edge

EL
• Fork
• Join

PT
• Decision
• Merge
• Synch
• Object
N
29
• The fundamental unit of execution Actions
an action is represented using a
rounded rectangle
and behavior modelling. Receive
order

EL
–Represents some processing steps
in the modeled system…

PT
–Examples: Receive order, Check
N
order, Ship order, Ship invoice, etc.
30
• Flows in an activity diagram do not have labels.
Flows
• Two types:
– Control-flow transitions indicate completion of an

EL
action and possibly start of another
– Object-flow

PT
transitions indicate
that an action inputs
N
or outputs an object

31
 Similar to state machines Controlling Steps

 Initial state

EL
 Final state

PT
 Fork and join
N
32
• Decision point and merge ( ):

Calculate [cost < 50] Charge


Cost Account

EL
[cost >= 50]

PT
N Get
Authorization

33
Initial and
• Initial node: filled circle. Final Nodes
• Final node: Circle around filled circle

EL
An activity diagram can have zero or more
final nodes

PT
N
First Action

34
• Denotes the beginning of parallel actions. Fork
Verify Order
Products Are In

EL
Stock

Receive

PT
Order
Verify Customer
Has Available
N Credit

35
Join
Verify Order

Accept Order

EL
Verify Customer

PT
N
36
• Swim lanes are used to represent Swim Lane
who performs which activities.
• Each action is assigned to one

EL
swim lane.

PT
• Activity flows can cross lanes.
• Relative ordering of swim lanes
N
has no semantic significance.

37
Customer Sales Stockroom

Request
service

EL
Take
Order
Pay

PT
Pack
Order

Collect
items
N
Dispatch
Items

38
Order
Object Flow
Take Order Pack Order
[Taken]

• Take Order produces an order object.

EL
• Pack Order takes an order object as input.

PT
• Dashed lines used with object flow have
N
the same semantics as normal transition.

39
Customer Sales Stockroom The transition
order object is taken by the sales
between an object
Request
parameter and an
service : Order
[placed] state changes from placed->entered
action state is
:Order represented with a

EL
[entered]
Take dashed line, instead
Order
Pay of a solid line

PT
state changes to filled
Pack
: Order Order
[filled]

:Order
[delivered]

Collect
N Deliver
order
order order flows are represented using dashed lines. Whereas the activity flows are
represented using solid lines,

40
Signals
• Signals are essentially messages with external
systems/processes.

EL
– Usually appear in pairs: sent and received signals, as
response is often expected for a sent signal.

PT
Request Receive
Payment Payment

Send signal
N Accept signal

41
• A received signal: Received Signals
– Indicates that the activity receives an event from
an outside process.

EL
– An activity gets reported of the signal, and it is
represented in the diagram how the activity reacts.

PT
• A time signal occurs on passage of time
N
– For example, each month end might trigger a signal.

42
Signals
• Look at signals are flow triggers...

EL
PT
Send signal Time signal Accept signal
N
43
Signal:
Process
Order
Request
Payment
Receive
Payment
Ship Examples
Order

EL
PT
Report
Receive Cancel Meter
Cancel Order Reading
Request
N At end of
month

44
Activity Diagram vs Flow Chart
• Can represent parallel activity and synchronization
aspects

EL
• Swim lanes:

PT
–Allows grouping activities based on who is
performing them
N
• Example: Academic department vs. Hostel

45
Initialize activity
Activity Diagram
Example: Student
Registration
Add student student registration

EL
fork/spawn

Notify Teacher Notify Billing

PT
Synchronization
[else]

guard
[ count < 100 ]
Nguard

Close course

46
Academic SectionAccounts Section Hostel Office Hospital Department
Another Example
check
student
Activity Diagram:
records
receive
student
fees admission
process at IIT

EL
allot create
hostel hospital
record

PT
register
receive
in
fees
course
conduct

N allot
room
medical
examination

issue
identity card

47
object oriented analysis and design

OOAD

EL
PT
N
48
• We discuss a design process based to a large extent A Design
Process
on Larman’s approach:

– Also synthesizes features from various


other methodologies.

EL
• From requirements specification, an initial model is

PT
developed (OOA):
N
– Analysis model is iteratively refined into a design model

• Design model is implemented using an OO language.

49
Iterative and Incremental OOAD

OOA OOD/OOP
Domain

EL
Specification Definition Model Construction
of of Program
Use
the problem case the solution

PT
model

N
50
• Analysis: OOA versus OOD?
– An elaboration of requirements.
– Independent of any specific implementation

EL
• Design:

PT
– A refinement of the analysis model.
– Takes implementation constraints into
account
N
51
OOD Design
OOA User interface
Issues or GUI
Use case Interaction Process
prototype diagram diagram Dynamic Behavior

Start

EL
SRS Domain Class
Code

PT
document model diagram
Conceptual Class Diagram

Glossary N
52
• Represent concepts or objects appearing Domain
in the problem domain. Model
– Also capture object relationships.

EL
• Three types of objects are identified:

PT
– Boundary objects
– Entity objects N
– Controller objects

53
Three different stereotypes are used to Class
represent classes : Stereotypes
<<boundary>>, <<control>>, <<entity>>.

EL
Control
Boundary

PT
BookIssue
Student Interface manager

Entity Book
N
54
Boundary Objects
• Handle interaction with actors:
–User interface objects

EL
• Often implemented as screens, menus, forms,
dialogs etc.

PT
• Do not perform processing:
N
–But may validate input, format output, etc.

55

You might also like