Object Oriented Analysis System modeling Functional modeling Object

Object Oriented Analysis • System modeling = Functional modeling + Object modeling + Dynamic modeling Describe • Functional modeling = Use cases the static • Object modeling =class diagrams structure of the • Dynamic modeling system – Interaction Diagrams • Sequence diagrams • Collaboration diagrams – State diagrams (activity diagrams) 1

Dynamic Modeling with UML • Two UML diagrams types for dynamic modeling: – Interaction diagrams describe the dynamic behavior between objects – Statechart diagrams describe the dynamic behavior of a single object. • Purpose: – Detect and supply operations for the object model. 2

UML Interaction Diagrams • Two types of interaction diagrams: – Sequence Diagram: • Describes the dynamic behavior of several objects over time • Good for real-time specifications – Collaboration Diagram: • Shows the temporal relationship among objects • Position of objects is based on the position of the classes in the UML class diagram. • Does not show time, 3

UML State Chart Diagram • State Chart Diagram: – A state machine that describes the response of an object of a given class to the receipt of outside stimuli (Events). • Activity Diagram: – A special type of state chart diagram, where all states are action states (Moore Automaton). • Classes without interesting dynamic behavior are not modeled with state diagrams 4

State Chart Diagram vs Sequence Diagram • State chart diagrams help to identify: – Changes to an individual object over time • Sequence diagrams help to identify: – The temporal relationship of between objects over time – Sequence of operations as a response to one ore more events.

Dynamic Modeling • We distinguish between two types of operations: – Activity: Operation that takes time to complete • associated with states – Action: Instantaneous operation • associated with events • A state chart diagram relates events and states for one class • An object model with several classes with interesting behavior has a set of state diagrams

UML State chart Diagram Notation Action Event with parameters attr State 1 do/Activity entry /action exit/action • Note: Event(attr) [condition]/action Name of State 2 Guard condition Actions and Activities in State – Events are italics – Conditions are enclosed with brackets: [] – Actions and activities are prefixed with a slash /

State • An abstraction of the attributes of a class – State is the aggregation of several attributes of a class • State has duration

Notations • A state is drawn as a rounded box containing a name. The state name appears in bold face • A transition is drawn as an arrow from the receiving state to the target state. Event names are written on the transition arrow, optionally followed by one or more attributes within parentheses. • A condition is a Bollean function of object values. Conditions can be guards on transitions. A guarded transition fires only when the event occurs and the condition is true. Conditions are shown as expressions in square brackets following the event name and its parameter list.

Example ATM machine • ATM machine object

Actions • An action follows the event name and/or the condition by the slash (/) character. • Events that cause an action without causing a state change are written inside the state box. • Internal transition: When it occurs, neither the entry nor exit action is executed. • Self-transition: when it occurs, entry and exit actions are executed. • Events sent to other objects are shown in dashed lines.

Self-transition Internal transition

Example of Vending Machine vending machine object coins_in(amount) / set balance Idle Collecting Money coins_in(amount) / add to balance cancel / refund coins [item empty] [select(item)] [change<0] Calculating do/Test item and compute change [change=0] Dispensing do/Dispense item [change>0] Dispensing change do/Make change
- Slides: 13