Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Above figure requires n2 transition to connect every state to other state. This can be reduced
to as low as n by using sub diagrams structure.
2. Expanding states
One way to organize a model is by having high level diagram with sub diagrams
expanding certain state. This is like a macro substitution in programming language
A submachine is a state diagram that may be invoked as part of another state diagram
Advanced State Diagrams & Interaction Model
Nested states:
Nested state : a state that shares behaviour from its composite state and adds additional
behaviour of its own.
Composite state: a state that provides shared behaviour for nested states.
Simplify the original complex state diagram.
States with common features and shared behaviors can be grouped or nested
inside composite states.
Composite state (active): labels the outer contour entirely encloses the nested
states.
Composite states are useful for expressing exception and error conditions
In the fig below, The transmission can be in reverse, neutral or forward, if it is in forward, it
can be in first, second or third gear. States first, second and third are the nested states of state
Forward. Each of the nested states receives the outgoing transitions of its composite state.
Selecting N in any forward gear shifts the transition to Neutral state. Selecting F in Neutral
causes a transition to Forward.
Advanced State Diagrams & Interaction Model
What are nested states? Explain with examples / nested states for a phone line.----5M
In the fig. below, All the original states other than Idle are nested states of Active. The
occurence of event onHook in any nested state causes a transition to state Idle. The Active
state is a composite state consisting of nested states DialTone, Dialing,Connecting etc
Signal generalization
You can organize signals into generalization hierarchy with inheritance of signal
attributes.
Ultimately, we can view every actual signal as a leaf on a generalization tree of
signals.
In a state diagram, a received signal triggers transitions that are defined for any
ancestor signal type.
Advanced State Diagrams & Interaction Model
**Concurrency
The state model implicitly supports concurrency among objects.
Objects are autonomous entities that can act and change state independent of one
another.
However objects need not be completely independent and may be subject to shared
constraints that cause some correspondence among their state changes.
1. Aggregation concurrency
State diagram for an assembly consist of collection of state diagram, one for each part.
Aggregate state (car) is combined states of all the parts.
Each part undergoes transition in parallel. Aggregation concurrency is the and-
relationship.
The aggregate state is one state from the first diagram, and a state from second
diagram and a state from each other diagram.
Transition for one object can depend on another object being in a given state.
Advanced State Diagrams & Interaction Model
The subdiagrams can be dependent: Same event can cause transition in more than one
subdiagram.
The state of the object comprises one state from each subdiagram.
The UML shows concurrency within an object by partitioning the composite state into regions
with dotted lines
state diagram for the play of bridge rubber.
When a side wins a game ,it becomes vulnerable. The first side to win two games
wins the rubber.
During the play, the state of the rubber consists of one state from each sub diagram.
Both sides are initially in their respective default states not vulnerable.
Each region can independently advance to state Vulnerable when its side wins a
game. When one side wins a second game, a transition occurs to the corresponding
wins cup .
This transition terminates both concurrent regions, because they are part of the same
composite state.
After dispensing the cash the machine must not reset itself until the user takes both the
cash & the card.
The user may take them in any order or even simultaneously.
2 concurrent substates becomes active and execute independently.
A transition that forks indicates splitting of control into concurrent parts. The
transition on event ready, splits into two concurrent parts, one to each concurrent sub
diagram.
The UML shoes the explicit merging of concurrent control by a transition with two
or more input arrows and one output arrow, all connected to a small heavy bar(not
shown in the above diagram). A completion transition fires when activity in the
source state is complete The composite concurrent state is complete when each of its
concurrent substrates is complete
Each Superclass and subclass has a state diagram and they interact.
If both Has Superclass and subclass has disjoint set of attributes then ---no problem
If both Has Superclass and subclass has same then conflict each other.
The state model of a class is inherited by its subclasses. It inherits both states and
transitions.
The state diagram of the subclass must concentrate only on the attributes unique to
subclasses.
In Signal hierarchy signals are considered as objects in classes and operation name as
signal name.
INTERACTION MODELING
The class model describes the objects in a system and their relationship.
The state model describes the life cycles of the objects.
The interaction model describes how the objects interact.
The interaction model starts with use cases that are then elaborated with sequence and
activity diagrams
Use case: focuses on functionality of a system- i.e, what a system does for users
Sequence diagrams: shows the object that interact and the time sequence of their
interactions
Activity diagrams: elaborates important processing steps
Use cases
A use case is a coherent piece of functionality that a system can provide by interacting with
actors.
1) A use case involves a sequence of messages among the system and its actors.
2) The UML icon for use cases is an ellipse shape with the name of the use case.
3) For example: A customer actor can buy a beverage from a vending machine. A
repair technician can perform scheduled maintenance on a vending machine.
4) Each use case involves one or more actors as well as the system itself.
5) Error conditions are also part of a use case.
6) A use case brings together all of the behavior relevant to a slice of system functionality
Use case description for Buy a beverage use case from vending machine use case
diagram
Advanced State Diagrams & Interaction Model
Use case diagram: a graphical notation for summarizing actors and use cases.
Draw the use case diagram for vending machine. What are the guidelines needed to be
followed while drawing use case models.-----10M
Advanced State Diagrams & Interaction Model
What are use case models? Give the guidelines for constructing the use case model.---
5M
Answer:
1. List three actors that are involved in the design of a checkout system. Explain the
relevance of each actor.
Customer: a person who initiates the purchase of an item.
Cashier: an employee who is authorized to check out purchase at a cash register.
Payment verifier: the remote system that approves use of a credit or debit card.
2. Take the perspective of a customer and list two use cases. Summarize the purpose of
each use case within a sentence.
Purchase items : a customer brings one or more items to the checkout register
and pays for the items.
Return items: the customer brings back items that were previously purchased
and gets a refund.
Answer:
Actor Description:
Sequence Models
What are sequence models? Describe the 2 kinds of sequence models. Draw the
sequence model for online stock broker system-----6M
Fig below shows a Scenario for a session with an online stock broker:
Advanced State Diagrams & Interaction Model
2. Sequence Diagram
Sequence diagram shows the participants in an interaction and the sequence of
messages among them.
A sequence diagram shows the interaction of a system with its actors to perform all or
part of a use case.
Each use case requires one or more sequence diagrams to describe its behavior.
Fig. below shows Sequence diagram for a session with an online stock broker.
thin rectangle shows Focus of control: period of time for an objects execution
vertical line shows Lifeline: period of time during which an object exists
Horizontal arrow shows each message from the sender to the receiver.
Advanced State Diagrams & Interaction Model
Fig. Below shows Sequence diagram for exception (purchase fails due to insufficient
fund):
Show the system response to the error condition with error condition sequence
diagram.
Activity Models
An activity diagram shows the sequence of steps that make up a complex process, such as an
algorithm or workflow.
Activity diagrams are most useful during the early stages of designing algorithms and
workflows.
Activity diagram is like a traditional flowchart in that it shows the flow of control
from step to step
Explain activity diagram with the UML notation. Give an example. ----5M
How an activity diagram differs from a traditional flowchart? Give the activity diagram
for stock trade processing.---8M
1. Activities
The computational steps of an activity diagram are activities/operations.
The purpose of an activity diagram is to show the steps within a complex
process
Activity run longer & can be interrupted by an event
An unlabeled arrow from one activity to another indicate, first activity must
complete before the second activity can begin.
2. Branches
Advanced State Diagrams & Interaction Model
If there is more than one successor to an activity, each arrow may be labelled with
a condition in square brackets.
In the case of multiple conditions, only One condition is satisfied
If No condition is satisfied then the diagram is badly formed, to avoid [else]
condition can be added.
Symbol: diamond
4. Concurrent activities
o fork of control (Synchronization bar) is used to Split activities into several
Concurrent activities
o Combined into single activity using merge of control
o Fork of control:
6. Guidelines
1. Dont misuse activity diagrams:
o Activity diagrams are intended to elaborate use case & sequence models
o Developer can study algorithms & workflow but never use for Developing
software.
2. Level diagrams:
o activities on a diagram should be at a consistent level of detail.
o Place additional detail for an activity in a separate diagram.
3. Be careful with branches & conditions:
Advanced State Diagrams & Interaction Model
Prepare an activity diagram for computing a restaurant bill. There should be a charge
for each delivered item. The total amount should be subject to tax. There is a service
charge of 18% for groups of six or more and give gratuity for smaller groups. Any
coupons and gift certificates submitted by the customer should be subtracted.
Advanced State Diagrams & Interaction Model
2. Extend relationship
1) Extend relationship adds incremental behavior to a use case.
2) In UML modeling, you can use an extend relationship to specify that one use
case (extension) extends the behavior of another use case (base)
3) The UML notation is a dashed arrow from the extension use case to the base
use case. The keyword <<extend>> annotates the arrow.
4) <<extend>> is a way of inserting new behavior into an existing use case.
5) Its like connecting an optional use case to a base use case. There is a loose
coupling between the base and extended use case.
Margin trading: use case gives loan for purchase when No sufficient
cash.
Short sale: allows borrowing the share & immediately sell them when
sufficient cash is available.
Limit order/ market order use case can be used when buying / selling
stock.
3. Generalization
o Parent use case gives general behavior sequence. It includes behavior common
to one or more use cases.
o Child use case inherits features from their parent use case. It can add new
features.
o Child use case can override inherited features.
o The UML convention: arrow with its tail on the child use case and a triangular
arrowhead on the parent use case, the same notation that is used for classes.
o Online stock brokerage system might specialize the general use case make
trade into the child use cases trade bonds, trade stocks and trade options.
Briefly discuss use case relationships and draw the use case diagram of stock broker
system-----8M
Advanced State Diagrams & Interaction Model
The secure session use case includes the behavior of manage accounts, make
trade validate password use cases.
Make trade is an abstract parent with the children-trade bonds, trade stocks
and trade options.
The make trade also includes the behavior of validate password.
The use case margin trading extends both trade bonds and trade stocks.
Use case limit order extends abstract use case make trade i.e. limit orders
apply to trading bonds, stocks and options.
The customer actor connects only the secure session use case.
The securities exchange use case connects to the make trade use case. This
actor does not initiate the use case but it is invoked during execution.
Prepare a use case diagram. Normally the customer pays cash for a gas purchase. Add
extend relationship to handle the incremental behaviour of paying by credit card
outside/ paying by credit card inside. Add include relationship to represent the optional
purchase of a car wash.
Advanced State Diagrams & Interaction Model
Answer:
Cashier: a person who take care of manual credit card payments & monitor sale
Purchase gas: perform function of obtaining gas & payment using cash
Purchase car wash: perform function of purchase car wash & payment using cash
Pay credit card outside: used for making payment which is directly handled by gas
system
Pay credit card inside: used for making payment which is manually handled by
cashier
ObjectC is created & destroyed during the time shown on the diagram, so its
lifeline does not span the whole diagram. It is a transient object.
Advanced features:
Be selective in using advanced features.
Create active & passive as necessary.
Show the implementation details for difficult and important sequence
diagrams.
Activity Diagrams have additional notation that is useful for large & complex applications.
1. Sending & receiving signals:
A signal represents one way communication between objects.
A signal send is modeled on an activity diagram as a convex pentagon labeled
with the name of the signal that is sent.
There is no action associated with this state, all it does is send the signal.
Advanced State Diagrams & Interaction Model
You can draw a dashed arrow from the signal send to the object that receives
the signal.
A signal receipt is modeled with a concave pentagon labeled with the name
of the signal that is received.
The signal receipt is just a state with no actions it merely receives the signal.
Consider a workstation that is turned on. It goes through a boot sequence and then
requests that the user log in.
After the entry of password, the workstation queries the network to validate the user.
Upon validation, the workstation finishes its startup process.
2. Swimlanes
Swimlanes is a column in an activity diagram that shows the person or
organization that perform activities.
The flight attendant must clean the thrash, the ground crew must add fuel, and
catering must load food and drink before the plane is serviced and ready for its
next flight.
Each swimlane shows which organization is responsible for an activity the
marketing department, the manufacturing department, and the delivery
department etc.
Each column in activity diagram is a swimlane
Lines across swimlane boundaries show interactions among different
organizations.
Advanced State Diagrams & Interaction Model
3. Object flows
An object flow shows how objects are input to or output from the activities.
Input/ output arrow shows control flow of objects
The same object may be input to or an output from several activities.
The same object may go through different states during the execution of activity
diagram.
The UML shows an object value in a particular state by placing the state name in
square brackets following the object name.
An airplane goes through several states as it leaves the gate, flies and then lands
again.