1 / 32

Chapter 13: Object State Modeling for Event-Driven Systems

Chapter 13: Object State Modeling for Event-Driven Systems. Key Takeaway Points. Object state modeling is concerned with the identification, modeling, design, and specification of state-dependent, reactive behavior of objects.

adrianac
Download Presentation

Chapter 13: Object State Modeling for Event-Driven Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 13: Object State Modeling for Event-Driven Systems

  2. Key Takeaway Points • Object state modeling is concerned with the identification, modeling, design, and specification of state-dependent, reactive behavior of objects. • The state pattern reduces the complexity of state behavior design and implementation, and makes it easy to change.

  3. OSM in the Methodology Context Use case-iteration allocation matrix Business goals & needs Current situation Accommodating Requirements Change Customer feedback Acquiring Requirements Iteration use cases Domain Modeling Preliminary requirements Domain model Domain model Deriving Use Cases from Requirements Actor-System Interaction Modeling Abstract & high level use cases, use case diagrams Expanded use cases & UI design Behavior Modeling & Responsibility Assignment Allocating Use Cases & Subsystems to Iterations Behavior models Use case-iteration allocation matrix Deriving Design Class Diagram Producing an Architecture Design Design class diagram Software architecture Test Driven Development, Integration, & Deployment (b) Iterative Phase – activities during each iteration (a) Planning Phase control flow data flow control flow & data flow

  4. Object State Modeling • Identification, modeling, analysis, design, and specification of state-dependent reactions of objects to external stimuli. • What are the external stimuli of interest? • What are the states of an object? • How does one characterize the states to determine whether an object is in a certain state? • How does one identify and represent the states of a complex object? • How does one identify and specify the state-dependent reactions of an object to external stimuli? • How does one check for desired properties of a state behavioral model?

  5. State Behavior Modeling • State dependent behavior is common in software systems. off park fwd brake on off up down reverse neutral on released transmission engine brake What is the state dependent behavior of a car?

  6. Basic Definitions • An event is some happening of interest or a request to a subsystem, object, or component. • A state is a named abstraction of a subsystem/ object condition or situation that is entered or exited due to the occurrence of an event.

  7. Object State Modeling Steps

  8. Collecting & Classifying State Behavior Information More rules are found in the textbook.

  9. Constructing a Domain Model • The domain model shows relationships between the state dependent software and its context. Source & Destination 1 resp. 1x resp. 1y resp. 2x resp. 2y event 1a event 1b Source & Destination 3 State Machine event 3a event 3b event 3c resp. 3x Source & Destination 2 event 2a event 2b

  10. Cruise Control Domain Model

  11. Constructing a State Transition Table • Constructing the state transition table is optional. • It is a systematic approach to state behavior modeling.

  12. Event stubs list the events. State stubs show the states. A single-line separates specialization substates Component substate A double-line separates component substates Transition entry, which means: if object is in S7 and E3 occurs and condition C is true, then actions a1 and a2 are executed and object enters S6. Specialization substate Table entry: initially all are “TBD.” Eventually, each should be “NA,” or a transition entry. State Transition Table State & Substate E1 E2 E3 S1 S2 S4 (init) TBD TBD TBD S5 TBD TBD TBD S3 S6 (init) TBD TBD TBD S7 TBD TBD S6 [C] / a1; a2 S8 S9 NA TBD TBD SA TBD S9 TBD

  13. Cruise Control State Transition Table

  14. Usefulness of State Transition Table • The systematic approach ensures internal completeness --- every state-event combination is analyzed. • State diagrams can be generated automatically. • It is easy to detect: • dead state • unreachable state • neglected event • impossible transitions • nondeterministic transitions • redundant transitions • inconsistent transitions

  15. Converting to State Diagram

  16. Converting Texts to Function Calls Cruise Activated leverUpAnd Hold() onOffButtonPressed() Cruising Cancelled Increasing Speed leverDown()/ setDesiredSpeed(), leverDown AndHold() Cruise Deactivated leverUpAnd Hold() leverUp() leverReleased() / setDesiredSpeed() leverPulled(), brakeApplied() onOffButton Pressed() Decreasing Speed Cruising leverReleased()/ setDesiredSpeed() leverDown AndHold() leverDown() / setDesiredSpeed()

  17. Add methods labeling the transitions to the subject class: Update Design Class Diagram CruiseControl onOffButtonPressed() leverDown() leverUp() brakeApplied() leverDownAndHold() leverUpAndHold() leverPulled() leverReleased() setDesiredSpeed()

  18. Implementing State Behavior • Conventional approaches: • nested switch approach • using a state transition matrix • using method implementation

  19. Conventional Implementation: Nested Switches Using nested switch statements switch (STATE) { case Init: switch (EVENT) { case State button clicked: set cursor to crosshair, STATE=AddState; break; case Trans button clicked: set cursor to crosshair; STATE=AddTransition; break; } case AddState: switch (EVENT) { ... } case AddTransition: switch (EVENT) { ... } case ... } Using a state transition matrix

  20. Conventional State Transition Matrix

  21. Using Method Implementation • State behavior of a class is implemented by member functions that denote an event in the state diagram. • The current state of the object is stored in an attribute of the class. • A member function evaluates the state variable and the guard condition, executes the appropriate response actions, and updates the state variable.

  22. Problems with Conventional Approaches High cyclomatic complexity (number of states multiplied by number of transitions). Nested case statements make the code difficult to comprehend, modify, test, and maintain. Difficult to introduce new states (need to change every event case). Difficult to introduce new events (need to change every state case). Solution: applying state pattern

  23. Transformation Schema for Real Time Systems • Ward and Mellor extended DFD with control flows and control processes. • Control processes are modeled by Mealy type state machines. • Control processes control the ordinary data transformational processes. • Control flows represent events or triggers to control processes and responses of control processes to transformational processes.

  24. Transformation Schema for Real Time Systems • Real time data flows, which must be processed quickly enough to prevent losing the data. • Data flows and control flows may be related using logical connectors. • Timing may be specified for state transitions and data transformation processes.

  25. Real Time Systems Design transformational processes, representing computations or information processing activities control processes, representing system’s state dependent behavior, which is modeled by a Mealy type state machine continuous data flow, which must be processed in real time ordinary or discrete data flow event flow or control flow that triggers a transition of the state machine of a control process, or a command from a control process to a transformational process

  26. Real Time Systems Design a indicates that both data flow a and data flow b are required to begin executing process P P b a indicates that either data flow a or data flow b is required to begin executing process P P + b These logical connector can be applied to both data flow and control flow and transformation process and control process.

  27. Real Time Systems Design Two subsets of Z are used by two different successor processes. X Z Y All of Z is used by two different successor processes. Z X Z is composed of Two subsets provided by two different predecessor processes. Z Y All of Z is provided by either one of two predecessor processes. Z

  28. brake resume Record Rotation Rate 2.2.2 enable/disable trigger rotation rate Cruise Control 2.2.1 start/stop increase speed speed reached enable/ disable throttle control Return to Previous Speed 2.2.5 enable/ disable enable/ disable rotation rate throttle position rotation rate Increase Speed 2.2.3 throttle control Maintain Constant Speed 2.2.4 rotation rate set point throttle control throttle position throttle position rotation rate Cruise Control Example

  29. enable/trigger “Record Rotation Rate”, enable “Maintain Constant Speed Maintain Speed brake/disable “Maintain Constant Speed” start increase speed/disable “Maintain Constant Speed”, enable “Increase Speed” stop increasing speed/disable “Increase Speed”, trigger “Record Rotation Speed” enable “Maintain Constant Speed” Increase Speed brake/disable “Increase Speed” Interrupted resume/enable “Return to Previous Speed” brake/disable “Return to Previous Speed” Resume Speed Cruise Control State Machine

  30. Timed State Machine • Time intervals can be used to label the state transitions. • The time intervals define the timing lower bounds and upper bounds allowed for processing the event and executing the list of actions. • The time interval can be decomposed to define the allowed times for processing the event, and executing each of the actions in the action list. • Similarly, time can be defined for state entrance action, state exit action, and state activity.

  31. State Diagram for Real Time Systems event/action [x,y] event/action [x] S1 S2 S1 S2 Time interval. Time interval. The time allowed for processing the event and executing the action is x to y time units. The time allowed for processing the event and executing the action is x time units. track(contact)/ (targetList.fit (contact)[5,8]) event[x,y]/ action[u,v] S1 S2 S1 S2 The time allowed for targetList object to fit the contact with a tracked target is 5 to 8 time units. The time allowed for processing the event is x to y time units and executing the action is u to v time units.

  32. Applying Agile Principles • Work closely with the customer and users to identify and model the state behavior. • Capture the state behavior at a high level, lightweight, and visual. • Value working software over comprehensive documentation—do barely enough modeling.

More Related