Lecture 6 - UML Sequence and State Diagrams Flashcards
What are UML Class Diagrams?
UML Class Diagrams describe the static structure of the system
– classes,
– class attributes,
– associations between classes,
– association roles and multiplicity
What are classes?
features and facts about the problem domain which matter in the system we are building to support it
Cinema Booking Example
REFER TO SLIDES
What are Sequence Diagrams represent?
Sequence diagrams represent
- the interaction of participants (horizontally)
- over time (vertically)
- using messages to communicate
What are Sequence Diagrams?
- Sequence diagrams represent the interaction of objects (horizontally) over time (vertically).
- SD ties use cases with objects, showing how the behaviour of a use case is distributed amongst its participating objects
- SD provide a shift in perspective, allowing developers to find missing objects or resolve uncertainties
- Developers should focus on problematic or under-specified functionality first, since drawing Sequence Diagrams can be time consuming
What are the most important components in Sequence Diagrams?
1.The participating objects – what are the objects associated with the use case in consideration
2.The flow of events between these objects – what are the messages that might be sent from the sender object to the receiver objects?
===
NOTE:
- Most of the main objects should have already been identified when we come to analyze sequence diagrams.
- Through dynamic modelling, new objects that were not identified may emerge.
What are the conventions for Sequence Diagrams?
Layout
Object Creation
Object Access
What are the conventions for Sequence Diagrams - Layout?
Layout:
1st column: corresponds to the actor who initiated the use case
2nd column: Should be a boundary object with which the actor interacts to initiate the case
3rd column: Should be the control object that manages the rest of the use case
4th column: An entity object representing long-lived info tracked by the
What are the conventions for Sequence Diagrams - Object Creation?
Object Creation:
– Control objects are created by boundary objects initiating the use case
– Other boundary objects are created by control objects
What are the conventions for Sequence Diagrams - Object Access?
Object Access:
– Entity objects are accessed by control and boundary objects,
– Entity objects should never access boundary or control objects:
This makes it easier to share entity objects across use cases
and makes entity objects resilient against technology-induced
changes in boundary objects.
Order Pricing Example
REFER TO SLIDES
Create New Online Library Account EXAMPLE
REFER TO SLIDES
When do you use Sequence Diagrams?
- You should use sequence diagrams when you want to look at the
behavior of several objects within a single use case. - Sequence diagrams are good at showing collaborations among the objects;
- they are not so good at precise definition of the behavior.
- If you want to explore multiple alternative interactions quickly, you may be better off with CRC cards, as that avoids a lot of drawing and erasing. It’s often handy to have a CRC card session to explore design alternatives and then use sequence diagrams to capture any interactions that you want to refer to later.
What are State Diagrams?
- A UML state diagram is a notation for describing the sequence of states an object goes through in response to external events.
- UML state machines are extensions of the finite state machine model.
- A state is a condition satisfied by the attributes of an object.
- A transition indicates a move from one state to another
- An event is a potential trigger for a change of state
What do State Machine Models show?
Show how individual objects change their state in response to events.
* They are represented in the UML using state chart diagrams.
* While sequence diagrams are used to model the combined behaviour of a group of objects in the system, the state chart diagrams are used to model the behaviour of a single object in response to external events.
* In the context of behaviour modelling, 2 different characterizations of states must be considered:
1. the state of each class, and
2. the state of the system as observed from the outside as the system performs its function
REFER TO SLIDES FOR DIAGRAMS
What are Statechart Diagrams?
- Graphs whose nodes are states and whose directed arcs are transitions labelled by events.
- States capture conditions which hold for a period of time
- Events change the state (except internal)
- Statechart diagrams represent behaviour from the perspective of a single object only– An object model with a set of objects must be represented by a set diagrams
What is a state and what are its characteristics?
- An abstraction of the attributes of a class– State is the aggregation of several attributes of a class
- Basically an equivalence class of all those attribute values and links that do not need to be distinguished as far as the control structure of the system is concerned – Example: State of a user interface screen
- logged in, logged out, active, idle
- active is an abstraction of all the user’s logged in activity
- State has duration
What is an Event?
- Something that happens at a point in time (e.g. button press, mouse click)
- Triggers a transition– Internal transition (no state change)– External transition (change to different state)
- May result in an action being executed
State Chart Diagram vs Sequence Diagram
- State diagrams help to identify:
– Changes to objects over time - Sequence diagrams help to identify
– The temporal relationships between objects over time
– Sequence of operations as a response to one or more events
When do you use state diagrams?
- State diagrams are good at describing the behavior of an object across several use cases.
- State diagrams are not very good at describing behavior that involves a number of objects collaborating.
- Therefore it is useful to combine state diagrams with other techniques.
- If you do use state diagrams, don’t try to draw them for every class in the system. … it is almost always a waste of effort.
- Use state diagrams only for those classes that exhibit interesting behaviour, where building the state diagram helps you understand what is going on.
- Many people find that User Interface and Control objects have the kind of behaviour that is useful to depict with a state diagram.