Monday, November 24, 2008

UML: state diagram

"To understand complex classes better, particularly those that act in different manners depending on their state, you should develop one or more UML 2 state machine diagrams, formerly called state chart diagrams in UML 1.x, describing how their instances work. "

"UML state machine diagrams depict the various states that an object may be in and the transitions between those states."

"A state represents a stage in the behavior pattern of an object, and like UML activity diagrams it is possible to have initial states and final states."

"An initial state, also called a creation state, is the one that an object is in when it is first created, whereas a final state is one in which no transitions lead out of. "

"A transition is a progression from one state to another and will be triggered by an event that is either internal or external to the object."

"The notation for the labels on transitions is in the format event [guard][/method list]. It is mandatory to indicate the event which causes the transition. Guard, conditions that must be true for the transition to be triggered, are optionally indicated."

"States are represented by the values of the attributes of an object....

It is possible to indicate the invocation of methods within a state. The notation used within the state (in this invocation of methods case) is the same as that used on transitions, the only difference being that the method list is mandatory and the event is optional....

Had there been no event indicated those methods would be invoked continuously (in a loop) whenever the object is in that state....

Methods to be invoked when the object enters the state are indicated by the keyword entry.
Methods to be invoked as the object exits the state are indicated by the keyword exit.

The capability to indicate method invocations when you enter and exit a state is useful because it enables you to avoid documenting the same method several times on each of the transitions that enter or exit the state, respectively." จะมาอธิบายเพิ่มด้วยรูปกับตัวอย่างอีกทีนะ

" You can have recursive transitions, also called self transitions, that start and end in the same state."

For the sake of convention, we say an object is always in one and only one state, implying transitions are instantaneous. Although we know this is not completely true (every method is going to take some time to run), this makes life a lot easier for us to assume transitions take no time to complete.


Depict Models Simply and Model in Small Increments

No comments: