Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003.

Slides:



Advertisements
Similar presentations
NCKU EE RTES LAB.1 Unified Modeling Language - Events and State Machines.
Advertisements

State Charts Mehran Najafi. Reactive Systems A reactive, event-driven, object is one whose behavior is best characterized by its response to events dispatched.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
ESE Einführung in Software Engineering 7. Modeling Behaviour Prof. O. Nierstrasz.
1 Behavioral Modeling Chapter 8. 2 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports business processes.
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 9 Slide 1 Appendix 3 Object-Oriented Analysis and Design.
State Transition Diagrams
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
1 Chapter 4 Dynamic Modeling and Analysis (Part I) Object-Oriented Technology From Diagram to Code with Visual Paradigm for UML Curtis H.K. Tsang, Clarence.
Interaction Diagrams Activity Diagram State Machine Diagram
Logic Based LSC Consistency Testing Presenter: Anup Niroula.
Slide 1 Systems Analysis & Design CS183 Spring Semester Dr. Jonathan Y. Clark Course Website:
Software engineering Methods Software Engineering Methods State Diagrams Zvi Avidor Written By With additions by Zvika Gutterman and Adam Carmi.
1 © Wolfgang Pelz UML2 UML Part 3. 2 © Wolfgang Pelz UML2 Chapter Ten State Machine Diagrams.
THE OBJECT-ORIENTED DESIGN WORKFLOW Statechart Diagrams.
Advanced Behavioral Modeling
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
Slide 1 Chapter 8 Behavioral Modeling. Slide 2 Key Ideas Behavioral models describe the internal dynamic aspects of an information system that supports.
SE-565 Software System Requirements More UML Diagrams.
State and Sequence Diagrams Modelling dynamic information So far we have seen: Use Case Diagrams – requirements capture, interface.
Chapter 5 – System Modeling
Lecture 4 Finite State Machine CS6133 Software Specification and Verification.
Chapter 10 State Machine Diagrams
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
מידול התנהגותי 1. Today’s Session Sequence Diagrams State Machines 2.
1 Object-Oriented Modeling Using UML (2) CS 3331 Fall 2009.
Software Engineering 1 Object-oriented Analysis and Design Chap 29 UML State Machine Diagrams and Modeling.
Fall 2010 CS4310 Requirements Engineering UML: Dynamic Modeling Dr. Guoqiang Hu Department of Computer Science UTEP 1.
1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling
Behavioral diagrams Lecture p4 T120B pavasario sem.
Using UML, Patterns, and Java Object-Oriented Software Engineering Chapter 2, Modeling with UML: Review Session (Optional)
Behavioral Modeling Chapter 8.
1 State Modeling  Events  States  Transitions and Conditions  State Diagrams  State Diagram Behavior  Practical Tips.
1 A Student Guide to Object- Oriented Development Chapter 7 State Diagrams.
Course Instructor: Kashif Ihsan 1. Chapter # 3 2.
Software Engineering Design & Modeling Statechart Diagram.
Modelling Class T07 Conceptual Modelling – Behaviour References: –Conceptual Modeling of Information Systems (Chapters 11, 12, 13 and 14)
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
Dynamic Models. Outline Dynamic Models Statecharts –States –Transitions –Composite states Interaction Diagrams –Sequence Diagrams The time order of interactions.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part VI: Design Continuous Activity Diagams State Diagrams.
OMT Modeling 1. Object Model : presented by the object model and the data dictionary. 2. Dynamic Model: presented by the state diagrams and event flow.
States.
CS3773 Software Engineering Lecture 06 UML State Machines.
Coming up: Interaction Diagrams Sequence Diagrams Dan Fleck.
Dynamic Modeling Grady Booch, James Rumbaugh, and Ivar Jacobson, The Unified Modeling Language User Guide, 2 nd edition, Addison Wesley, 2005.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 26. Review UML behavioral Diagrams – Sequence diagram.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
MCS 270 Spring 2014 Object-Oriented Software Development.
Modeling Object Lifecycles and State-Dependent Behavior ©SoftMoore ConsultingSlide 1.
The Dynamic Analysis Model StateCharts Prof. Hany H. Ammar, CSEE, WVU, and Dept. of Computer Science, Faculty of Computers and Information, Cairo University.
Chapter 7 Behavioral Modeling Brandon A. Jones Stand and Deliver ITEC March 6, 2011.
Module 2 OOMD.
Test Generation from UML Specifications Michael A. Gray American University Washington, DC.
State Modeling. Introduction A state model describes the sequences of operations that occur in response to external stimuli. As opposed to what the operations.
UML Review: State Machines. Sept. 17, 2003Lecture 5: CS660 Fall Overview States Transitions Activities Modeling object lifeline Creating well-structured.
State transition modeling
State Machine Model.
State Diagram – Advanced Concepts
Dynamic Modeling of Banking System Case Study - I
Visit for more Learning Resources
State Machine Diagrams
UML State Diagrams.
CS251 – Software Engineering Lectures 11 State Diagrams
States.
Object Oriented System Design
Chapter 5 state Modeling
States.
UML State Diagrams.
Modeling Behavior in Statechart Diagrams
Presentation transcript:

Object-Oriented Modeling Using UML CS 3331 Section 2.3 of Jia 2003

Outline  State machine diagram Basic elements Protocol vs behavior state machines Structuring state machines  Sequence diagram 2

Dynamic Models  Used to model control aspects (e.g., when)  Several different models possible, e.g., State machine diagram: focusing on state changes Interaction diagram: focusing on interactions  Sequence diagram: time order of interactions between objects  Communication diagram: messages passed between objects 3

State Machine Diagram  Depicts the flow of control using states and transitions by describing How an object or system changes over time Event (e.g., operation calls) it may respond to How it respond to them  Generalization of finite state machines  Good for modeling reactive systems 4

Modeling Object States  Graph representing finite state machine  Network of states and transitions OnOff button pressed 5

Elements of State Machine Diagram Idle Initial state Running Final state State Transition 6

State  Condition or situation in the life of a system (or object) during which it: Satisfies some condition, Performs some activity, or Waits for some events.  Set of values of properties that affect the behavior of the system (or object). Determines response to an event, Thus, different states may produce different responses to the same event 7

State (Cont.)  Examples The invoice is paid. The car is parked. The engine is running. Kate is working. Jim is playing. All ships are placed. A Game is over. The system is waiting for a player shot. 8

Transition  Relationship between two states indicating that a system (or object) in the first state will: Perform certain actions and Enter the second state when specified event occurs and specified condition is satisfied.  Consists of: Source and target states Optional event, guard condition, and action Source Event [Condition] / Action Target 9

Definition  Event An occurrence of a stimulus that can trigger a state transition Instantaneous and no duration  Action An executable atomic computation that results in a change in state of the model or the return of a value keyPressed(k) [k == ENTER_KEY] / buf := input 10

Example OffOn pressed/turn on light pressed/turn off light 11 Q: Model a night light that automatically turns on and off?

Outline  State machine diagram Basic elements Protocol vs behavior state machines Structuring state machines  Sequence diagram 12

Protocol vs. Behavior Machines  Protocol state machine Specifies the intended pattern of calls on an object by specifying  which operations of the object can be called in which state  and under which condition, thus specifying the allowed call sequences on the object's operations. Describes an object's life cycle. Post-conditions are used instead of actions  Behavior state machine Expresses the behavior of part of a system, e.g., to define object and operation behavior Actions are used instead of post-conditions States can have actions (entry, exit, do) 13

Protocol State Machine Not Overdrawn [balance >= 0] Overdrawn [balance < 0] deposit(x) withdraw(x)[balance - x >= 0] deposit(x)[balance + x < 0] deposit(x)[balance + x >= 0] withdraw(x)[balance - x < 0] Account -balance: int + withdraw(x: int): void + deposit(x: int): void 14

Behavior State Machine Searching [i <= N && a[i] != v] / k := -1; i = 0 [a[i] = v] / k := i [i < N && a[i] != v] / i := i + 1 [i >= N && a[i] != v] 15

In Class: Digital Watch  (Pairs) Draw a state machine diagram The watch has a single mode button and a single advance button. Pressing the mode button once and then pressing the advance button increments the hours by 1. Each press of the advance button increments the hour. Pressing the mode button the second time allows advancing the minutes by one. Pressing the mode button a third time displays the current time. While displaying the current time, the advance button is ignored. Pressing the mode button allows the user to set the hour again. 16

More on States  Optional internal activities Actions and activities performed while in the state Predefined: entry, exit, do  Optional internal transitions Reaction within a state but without changing state Name Internal activities Internal transitions 17

Internal Activities and Transitions  Internal activities Entry: performed on entry to state Exit: performed on exit from state Do: performed while in the state  Internal transitions Reactions to events that doesn’t cause state changes Attacking entry/unsheathe sword do/charge exit/sheathe sword enemy swings[distance<3 ft]/dodge 18

Example Starting entry / start dial tone exit / end dial tone Dialing entry / number.append(n) dialed (n) [number.isValid()] 19

Outline  State machine diagram Basic elements Protocol vs behavior state machines Structuring state machines  Sequence diagram 20

Structuring Diagrams anomaly Normal Recovery Identification Pressure Recovery Temperature Recovery recovery success recovery success temperature pressure recovery failure recovery failure recovery failure Can this diagram be presented better? 21

Composite States anomaly Normal Recovery Identification Pressure Recovery Temperature Recovery recovery success temperature pressure Recovery recovery failure 22

Composite States (Cont.)  Used to simplify diagrams  Inside, looks like state machine diagram  May have composite transitions  May have transitions from substates  Sequential (OR) and parallel (AND) states 23

Composites and Transitions Idle Maintenance Printing Selecting Processing Validating Transition from substate Transition to/from composite state Active 24

Exercise  Model a night light that Automatically turns on and off when it becomes dark or bright. Has a button to select a light color: white, blue, and red. The initial color is white, and pressing the button while the light is on changes it to the next color. 25

Parallel Composition  Concurrency (split of control)  Synchronization substate1substate2 Superstate substate3substate4 26

Example 27

Exercise  Model a night light that Automatically turns on and off when it becomes dark or bright. Has a button to select a light color: white, blue, and red. The initial color is white, and pressing the button changes it to the next color in the color sequence. The button works regardless whether the light is on or off. 28

Outline State machine diagram  Sequence diagram 29

Sequence Diagram  Describes a sequence of method calls among objects  Highlights the time ordering of method calls 30

Example message lifetime control object 31

Example (Cont.) Sequence of message sending 32