Docsity

Statecharts: Modeling State-Dependent Responses to Events for Each Class, Slides of Object Oriented Programming

Partial preview of the text

Download Statecharts: Modeling State-Dependent Responses to Events for Each Class and more Slides Object Oriented Programming in PDF only on Docsity!

Specifying Control

Lecture 24

Overview

n How statecharts fit with other UML diagrams?

n States and Events

n Basic statechart notation

n Some example statecharts

Control and State

n Different UML diagrams portray different aspects of

an Information System

n Class Diagrams

n Static Structure

n Interaction Diagrams

n The way in which objects interact

n Statecharts

n How the system responds to events

docsity.com

Statecharts

n Model "state dependent" responses to events

n One statechart for each class

n A statechart captures all possible responses of a

single object to all the use cases in which it is

involved

n Describes the possible life cycles an object of a class

can follow

Statecharts:

One Statechart for Each Class

Example:

Statechart for Course class

Initialization Open entry: Register student exit: Increment count

Closed

Canceled

do: Initialize course

do: Finalize course

do: Notify registered students

Add Student / Set count = 0

Add student[ count < 10 ]

[ count = 10 ]

Cancel

Cancel

Cancel

teach

Possible life cycles

docsity.com

Transitions and Events

n Transition

n Movement from one state to another

n Event

n Change event: condition become true

n Call event: receives a call from another object

n Signal event: receives a signal

n Time event: caused by passage of designated period of time

or after a specific event

Basic Statechart Notation

Basic Statechart Notation

Internal Actions and Activities

docsity.com

Example

MenuVisible state for DropDownMenu

Example

Statechart for Garage Door

Example

Alternative statechart for Garage Door

docsity.com