Using UML Patterns and Java ObjectOriented Software Engineering

Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 5, Analysis: Dynamic Modeling

Outline of the Lecture ¨ Dynamic modeling w Sequence diagrams w State diagrams ¨ ¨ Using dynamic modeling for the design of user interfaces Analysis example Requirements analysis document template Requirements analysis model validation Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 2

How do you find classes? ¨ In previous lectures we have already established the following sources w Application domain analysis: Talk to client to identify abstractions w Application of general world knowledge and intuition w Scenarios t Natural language formulation of a concrete usage of the system w Use Cases t Natural language formulation of the functions of the system w Textual analysis of problem statement (Abbott) ¨ Today we show identify classes from dynamic models w Actions and activities in state chart diagrams are candidates for public operations in classes w Activity lines in sequence diagrams are also candidates for objects Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 3

Dynamic Modeling with UML ¨ Diagrams for dynamic modeling w Interaction diagrams describe the dynamic behavior between objects w Statecharts describe the dynamic behavior of a single object ¨ Interaction diagrams w Sequence Diagram: t t Dynamic behavior of a set of objects arranged in time sequence. Good for real-time specifications and complex scenarios w Collaboration Diagram : t ¨ Shows the relationship among objects. Does not show time State Chart Diagram: w A state machine that describes the response of an object of a given class to the receipt of outside stimuli (Events). w Activity Diagram: A special type of statechart diagram, where all states are action states (Moore Automaton) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 4

Dynamic Modeling ¨ Purpose: w Detect and supply methods for the object model ¨ How do we do this? w Start with use case or scenario w Model interaction between objects => sequence diagram w Model dynamic behavior of a single object => statechart diagram Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 5

Start with Flow of Events from Use Case ¨ Flow of events from “Dial a Number” Use case: w w w w Caller lifts receiver Dial tone begins Caller dials Phone rings Callee answers phone Ringing stops. . Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 6

Sequence Diagram ¨ ¨ ¨ From the flow of events in the use case or scenario proceed to the sequence diagram A sequence diagram is a graphical description of objects participating in a use case or scenario Relation to object identification: w Objects/classes have already been identified during object modeling w Objects are identified as a result of dynamic modeling ¨ Heuristic: w A event always has a sender and a receiver. w The representation of the event is sometimes called a message w Find them for each event => These are the objects participating in the use case Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 7

Heuristics for Sequence Diagrams ¨ Layout: w 1 st column: Should correspond to the actor who initiated the use case w 2 nd column: Should be a boundary object w 3 rd column: Should be the control object that manages the rest of the use case ¨ Creation: w Control objects are created at the initiation of a use case w Boundary objects are created by control objects ¨ Access: w Entity objects are accessed by control and boundary objects, w Entity objects should never call 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. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 8
![UML Statechart Diagram Notation Event trigger With parameters State 1 Event 1(attr) [condition]/action do/Activity UML Statechart Diagram Notation Event trigger With parameters State 1 Event 1(attr) [condition]/action do/Activity](http://slidetodoc.com/presentation_image_h2/c0f6d8adc491d091041cf71e614080f4/image-9.jpg)
UML Statechart Diagram Notation Event trigger With parameters State 1 Event 1(attr) [condition]/action do/Activity entry /action exit/action Guard condition State 2 Also: internal transition and deferred events ¨ Notation based on work by Harel w Added are a few object-oriented modifications ¨ A UML statechart diagram can be mapped into a finite state machine Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 9

Statechart Diagrams ¨ ¨ Graph whose nodes are states and whose directed arcs are transitions labeled by event names. We distinguish between two types of operations in statecharts: w Activity: Operation that takes time to complete t associated with states w Action: Instantaneous operation t t ¨ associated with events associated with states (reduces drawing complexity): Entry, Exit, Internal Action A statechart diagram relates events and states for one class w An object model with a set of objects has a set of state diagrams Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 10

State ¨ An abstraction of the attributes of a class w State is the aggregation of several attributes a class ¨ Basically an equivalence class of all those attribute values and links that do no need to be distinguished as far as the control structure of the system is concerned w Example: State of a bank t ¨ A bank is either solvent or insolvent State has duration Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 11

Example of a State. Chart Diagram coins_in(amount) / set balance Idle Collect Money coins_in(amount) / add to balance cancel / refund coins [item empty] [select(item)] [change<0] do: test item and compute change [change=0] do: dispense item Bernd Bruegge & Allen H. Dutoit [change>0] do: make change Object-Oriented Software Engineering: Using UML, Patterns, and Java 12

State Chart Diagram vs Sequence Diagram ¨ State chart diagrams help to identify: w Changes to an individual object over time ¨ Sequence diagrams help to identify w The temporal relationship of between objects over time w Sequence of operations as a response to one ore more events Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 13

Dynamic Modeling of User Interfaces ¨ Statechart diagrams can be used for the design of user interfaces w Also called Navigation Path ¨ States: Name of screens w Graphical layout of the screens associated with the states helps when presenting the dynamic model of a user interface ¨ Activities/actions are shown as bullets under screen name w Often only the exit action is shown ¨ State transitions: Result of exit action w Button click w Menu selection w Cursor movements ¨ Good for web-based user interface design Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 14

Navigation Path Example Diagnostics Menu • User moves cursor to Control Panel or Graph Control panel • User selects data group and • User selects functionality of sensors type of graph Define • User defines a sensor event from a list of events Enable • User can enable a sensor event from a list of sensor events List of events • User selects event(s) Bernd Bruegge & Allen H. Dutoit Disable • User can disable a sensor event from a list of sensor events List of sensor events • User selects sensor event(s) Selection • User selects data group • Field site • Car • Sensor group • Time range • User selects type of graph • time line • histogram • pie chart Visualize • User views graph • User can add data groups for being viewed Link • User makes a link (doclink) Object-Oriented Software Engineering: Using UML, Patterns, and Java 15

Practical Tips for Dynamic Modeling ¨ Construct dynamic models only for classes with significant dynamic behavior w Avoid “analysis paralysis” ¨ Consider only relevant attributes w Use abstraction if necessary ¨ ¨ Look at the granularity of the application when deciding on actions and activities Reduce notational clutter w Try to put actions into state boxes (look for identical actions on events leading to the same state) Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 16

Summary: Requirements Analysis Functional Modeling 1. What are the transformations? w Create scenarios and use case diagrams t Talk to client, observe, get historical records, do thought experiments 2. What is the structure of the system? Object Modeling Create class diagrams Identify objects. What are the associations between them? What is their multiplicity? What are the attributes of the objects? What operations are defined on the objects? ¨ Dynamic Modeling 3. What is its behavior? Create sequence diagrams Identify senders and receivers Show sequence of events exchanged between objects. Identify event dependencies and event concurrency. Create state diagrams Only for the dynamically interesting objects. Bernd Bruegge & Allen H. Dutoit Object-Oriented Software Engineering: Using UML, Patterns, and Java 17
- Slides: 17