210 likes | 335 Vues
This document provides an overview of dynamic information modeling, focusing on the use of UML tools like State Diagrams and Object Sequence Diagrams (OSD) for capturing runtime behavior in software systems. It explains how state diagrams depict the life cycle of an object, including state changes triggered by events, while OSDs visualize interactions among classes. It emphasizes the importance of understanding events, guards, and internal state behaviors in modeling dynamic systems and improving software design.
E N D
n.a.shulver@staffs.ac.uk Modelling dynamic information • So far we have seen: • Use Case Diagrams – requirements capture, interface modelling • Use Case Scripts – more detailed and with alternate, less common cases noted • Class Diagrams – description of the structure of a class and possibly its relationship with other classes • These are static descriptions of software
n.a.shulver@staffs.ac.uk Dynamic Modelling • In order to model the dynamic (run-time) relationships we need different tools • The UML provides us with State Diagrams and Object Sequence Diagrams (OSD) • There are others...
n.a.shulver@staffs.ac.uk State Diagrams • What do state diagrams describe? • When things happen • The life-cycle of an instance (object) • How useful are they? • Often but not always used • Logically links a Class Diagram to a State Diagram – events are operations on classes in the Class Diagram • Clarifies the internal state and external behaviour of an object
n.a.shulver@staffs.ac.uk State Diagram Elements start point states end point(s) transitions (labeled with events)
n.a.shulver@staffs.ac.uk State Diagram examples A chess game class • White takes the first turn, then turns alternate • After any move “mate” or “stalemate” may occur
n.a.shulver@staffs.ac.uk State Change Events • A state describes a particular condition of an object for a period of time – it waits for an event to change state or to “fire” • Events can be of the following types: • Change – occurs when a condition becomes true i.e. a boolean • Call/Signal – occurs when an object receives a call for one of its operations (from another object or from itself) • Time trigger
n.a.shulver@staffs.ac.uk Guards • Known as a guard condition • It guards the transition i.e. the transition can only take place if the guard condition evaluates to true • Guards are constraints on behaviour • Example in Visio
n.a.shulver@staffs.ac.uk Event Types • Kinds of events • receipt of a call on an operation - a message • receipt of an explicit signal from another object - a message • a condition becoming true • passage of a designated period of time • Basic semantics about event labelled transitions • events are triggers that activate state transitions • if an event occurs and guard is false then the event is ignored (events are not stored)
n.a.shulver@staffs.ac.uk Visio Support – State Chart
n.a.shulver@staffs.ac.uk Inside States • Three kinds of internal content for a state • These represent the internal activities or state activities that are executed in that state • Entry actions • Exit actions • Internal transitions - do not cause a state change • All the above represent the operations for the class that is being modelled
n.a.shulver@staffs.ac.uk How to find States • A state chart captures all the possible responses of a single object to all the Use Cases in which it is involved • So a cross reference of which of the Use Cases a class is involved in will give you possible states for an object of that class • The state chart can be seen as a description of all the possible life-cycles for an object • Provides a dynamic view of a class
n.a.shulver@staffs.ac.uk Object Sequence Diagrams • OSDs depict a Use Case Script visually but also show the classes (objects) used in the script • They show the sequence of object interaction • Read the Visio tutorials for detailed information on the Sequence Chart • The next slides show example Sequence Charts
n.a.shulver@staffs.ac.uk Simple Example
n.a.shulver@staffs.ac.uk Sequence Diagrams • Purpose • Captures the behaviour of a single use case - how messages are sent within a use case • Shows how objects interact with each other - show how they send and receive messages • Focuses on time • Syntax • Object • Time • message
n.a.shulver@staffs.ac.uk Sequence Diagram • Example
n.a.shulver@staffs.ac.uk Sequence Diagram • Types of messages • simple • flat flow of control - control is passed without describing any details • synchronous • nested flow of control - operation call • handling of the message is completed before the caller resumes execution • asynchronous • there is no explicit return to the caller • the sender continues to execute after sending the message without waiting for it to be handled
n.a.shulver@staffs.ac.uk Sequence Diagram • Activation • Time during which object performs an action either directly or through another object (subcontractor) • Return • Implicit • Explicit
n.a.shulver@staffs.ac.uk Drawing an OSD • Select a Use Case for which you have a Script • Make a list of classes which appear on that script (you may have done this already if you have created a Class Diagram) • Use Visio to create a new Sequence Diagram • Do the simple things first and build it up • Place the objects (classes) on the diagram • Think about the order that you put them in
n.a.shulver@staffs.ac.uk Drawing an OSD • When creating messages, for the first draft just use the simple message call shape • Refine to synchronous or asynchronous at the 2nd draft • Finally, put the rectangle duration box (operation life) overlay onto the timeline for each object • Then review it and do a 2nd draft
n.a.shulver@staffs.ac.uk Self-paced tutorial • Create a State Diagram in Visio for the third version of the example Soup Menu application • Hints: states include ingredient choice (three types) and action choice • What kind of transitions are there? - write down a list • Hints: remember that each transition is a flow from one state to another • Finally, what events/actions are there for the transitions in your list?