Unit 3
Unit 3
Unit
DYNAMIC AND
IMPLEMENTATION UML DIAGRAMS
Different checking processes are added. Each checker is called asynchronously and
proceeds in parallel.
When transaction checker completes, it informs transaction coordinator. After all checkers
are completed the coordinator notifies the transaction that all is well.
The half arrow heads indicate asynchronous message. It does not block the caller but
carries its own processing. It does one of the following things.
1) Create a new thread, in which case it links to the top of an activation.
2) Create a new objects
3) Communicate with a thread that is already running.
It shows the objects participating in interaction by their life lines and the messages they
exchange, arranged in a time sequence.
offhook
Dialtone
Dial Number RingTone
offhook
onhook
Exchange
4:Ringtone
Receiver
r
5:offHook 6:onHook
Talk
Figure 3.3
Dynamic and Implementation UML Diagrams 3.5
With Decimal Numbering
With Decimal
Numbering
Exchange
2.2:Ringtone
Receiver
3.1:offHook 4.1:onHook
Talk
:OrderEntryWindo Object
w Sequence Number
1 : prepare () Message
5 : needReorder := needToReorder ()
:Order
2* [for all order lines]:prepare ()
3: hasstock:=check() Self Delegation
4:[hasstock]: remove()
Macallanline:Orderli MacallanStock: StockItem
ne
[has stock]:new 6.[needsReorder]:new
Figure 3.4
3.6 Object Oriented Analysis and Design
Collaboration Diagram With Decimal Numbering
:OrderEntryWindow
Sequence Number
1: prepare()
1.1.2.1: Need Reorder
:Order := need ToReorder()
Figure 3.5
The same kind of information are added regardless of what numbering systems used.
Sequence diagram puts emphasis on sequence. It is easy to see the order in which the
things occur.
Collaboration diagram uses the layout to indicate how objects are statically connected.
Figure 3.7
The door can be in one of three states: "Opened", "Closed" or "Locked". It can respond to
the events Open, Close, Lock and Unlock. Notice that not all events are valid in all states; for
example, if a door is opened, you cannot lock it until you close it. Also notice that a state
transition can have a guard condition attached: if the door is Opened, it can only respond to the
Close event if the condition doorWay->isEmpty is fulfilled. The syntax and conventions used in
state machine diagrams will be discussed in full in the following sections.
3.8 Object Oriented Analysis and Design
States
A state is denoted by a round-cornered rectangle with the name of the state written inside
it.
Figure 3.8
Transitions
Transitions from one state to the next are denoted by lines with arrowheads. A transition
may have a trigger, a guard and an effect, as below.
Figure 3.9
The name compartment holds the optional name of the state. States without names are
anonymous.
Dynamic and Implementation UML Diagrams 3.9
The internal transition compartment holds a list of internal actions or activities performed
in response while the object is in the state, without changing states.
digit (n)
Figure 3.10
A complex transition
Figure 3.11
State diagrams describe all the possible states that a particular object can get into and how
the objects state changes as a result of events that reach the object. They describe the behavior of a
system.
We begin at start point.
An initial transition called as “/getfirstitem”. Leads to the checking state.
Syntax for transition label
Event[Guard]/Action
All are optional. In this case we have the action “get first item”
Checking state has an activity associated with it do/checkitem.
Syntax: do/activity
Action for transaction and Activity for the state.
3.10 Object Oriented Analysis and Design
UML state diagram for an order in the order processing system.
Actions
Actions are associated with transitions. They are the processes that occur quickly and are
not interruptible.
For a real time system “quickly” may be within s few machine instruction.
For regular information systems, “quickly” means less than few seconds.
Activity
Activities are associated with states and can take longer. An activity may be interrupted by
some event.
When no events are there in the transaction label, transition occurs as soon as any activity
associated with the given state is completed.
Here after completing checking state, there transitions come out. All the three have only
guards on their label.
Guard
A guard is a logical condition that will return only “true” or “false”. A guarded transition
only if the guard resolves to “true”.
One transition is taken out of given state, so the guards are mutually exclusive for any
event. We got 3 conditions.
1) If we have not checked all items. We get the next item and return to checking state.
2) If we have checked all items and were all in stock, we transition to dispatching state.
3) If we have checked all items but not all of them in the stock, we transition to the
waiting state.
Waiting State
Then we have waiting state. There are no activities for this state.
Two transactions are out of waiting state labeled ItemReceived event.
From the waiting state, guards on the transitions are evaluated and appropriate transitions
are made either to Dispatching or back to waiting.
Dispatching State
From dispatching state, an activity initiates delivery. There is alos a single unguarded
transition triggered by delivered event.
Once the “initiate delivery” activity is finished, given order remains in the Dispatching
state until delivered event occurs.
Dynamic and Implementation UML Diagrams 3.11
The final thing is the transition called “cancelled” we ant to cancel at any point. We cab
draw separate transition from checking, waiting and dispatching. Alternative is to create a
superstate of all 3 states and draw single transition from that.
Cancelled Cancelled
Figure 3.12
State Diagram With Superstates
Superstate name
Active
[Not all items checked] [ALL ITEMS CHECKED &&
/get next item
Checking Dispatching
do/check All items available do/initiate
item delivery
[All items checked &&
some items not in stock]
Item received [all
Item Received [some item available]
items not in stock]
Waiting
Cancelled Delivered
Figure 3.13
There are a couple of other types of events in addition to named events from outside.
An event generated after a period of time. This is indicated with the keyword “after”.
3.12 Object Oriented Analysis and Design
Example: We say after (20 minutes)
An event can be generated when condition becomes true. Keyword is “when”
Example: when (temperature > 120 degrees)
Special Events
The special events are entry and exit
An entry event is executed whenever the given state is entered fro transaction.
If the transition goes back to the same state with an action, exit is executed first, then
transition action and finally entry action. Such transition is called self transition.
If several complicated concurrent state diagrams are there for an objects, then split the
objects into separate objects.
Payment Authorization
Figure 3.14
Here we begin by doing authorization. Check payment “activity finishes and approves
payment.
If payment is “OK”, order waits in Authorized state until “deliver” event occurs.
Otherwise order enters Rejected state.
Dynamic and Implementation UML Diagrams 3.13
Concurrent State Diagram
Figure 3.15
The associated states and the cancelled states are combined on a concurrent state diagram.
In concurrent sections of state diagrams, the given order is in 2 different states.
If “check payment” activity of the Authorizing state completes successfully, the order will
be in checking and Authorized states.
If “cancel” event occurs, the order will be in cancelled state.
Activity diagram is similar to state chart diagram where a token represented an operation.
An activity is shown as a round box, containing name of operation.
Activity diagram shows internal state of object but external events ay also appear. The two
possible states in activity diagram are wait state and activity state.
3.14 Object Oriented Analysis and Design
An Activity Diagram for Processing Mortgage Requests
Prepare incoming
documents
Index documents
Make
electronic file
Complete request
Pay provision to
Calculate data for
insurance agent
construction
mortgage
Draw up
insurance policy
Figure 3.16
The business processes are very complex and hence it is better to represent them in
pictures rather than text.
Activity diagrams are highly are highly useful for these purpose.
Dynamic and Implementation UML Diagrams 3.15
In Gane-Sarson notation of DFD the process steps are numbered to indicate order.
3.16 Object Oriented Analysis and Design
In addition to the object nodes the UML activity diagram includes „datastore‟ node for the
above example.
Figure 3.19
Dynamic and Implementation UML Diagrams 3.17
Action may be organized into swim lanes each separated from its neighboring swim lanes
by vertical solid lines on both sides.
3.1.7.1 Guidelines
1) Activity diagrams are used for complex processes.
2) In Business process modeling used „rake‟ notation and sub activity diagrams.
Level 0 – very high level of abstraction
Level 1 – expand the details
Level 2 – more expansion and so on
3) Levels of abstraction must roughly be equal within a diagram.
Example
The „Process Sale‟ usecase is shown as an Activity diagram
3.18 Object Oriented Analysis and Design
Figure 3.21
Activity diagrams are applicable within the business modeling discipline of UP.