Wednesday, 6 February 2013

State Transition Diagram

One way to characterize change in a system is to say that its objects change their state in response to events and to time

  • e.g. When you throw a switch, a light changes its state from off to on
  • e.g. The update_mark method changes the state of the student subject object
A state diagram shows the various states of a single object
  • There must be a separate transition diagram for each object class
  • It helps analysts, designers and developer understand the behavior of the objects in the system,
  • State diagrams ensure that they won't have to guess about what the object is supposed to do
When do we care about States?

  1. A class has a complex life cycle
  2. Properties of the class may be updated at multiple points in the life cycle
  3. When one class is dependent on the existence or behavior of other classes
  4. When the behavior of a class depends on what previously happened
We can definitely say that state transition diagram show class state and the events that cause them to transition between states.
  • An event happens at a specific time and place
  • Events cause a change of state for the object as the transition "fires"
Each time on object changes state, some of its attributes must change
  • There must be a method in the object class to change the attributes
  • Often there is a boundary or interface class ( a display screen or web form) for the actor to enter the attributes and trigger the Event

2 comments: