As we know , initial state is the initial state of the system before the activity begins and the final state is the final state of the system when the activity ends. But what exactly is the initial and final state in activity diagram? I mean , for example , there supposed to be a text on the these elements to illustrate what exactly the state (initial / final ) of the system should be in ?? please someone givean example to explain these elements.
The activity diagram models flows of control and flows of objects. There is no initial or final state in such diagrams. But there are
- initial nodes that shows where the flow starts when the activity starts. There could be several, since activities allow concurrency.
- final nodes that end the flow.
The logic of the nodes is about control tokens. When an activity starts, every initial node gets a token. These tokens follow the flow and trigger actions until the activity is ended.
This is very different from the logic of states. States represent a situation during which "some invariant conditions hold". Events cause transition to other states. The initial state is a temporary pseudostate that shows where to find the first real state.
Examples related to online purchasing/booking:
- the activity diagram shows the sequence of actions: the initial node immediately leads to a choice between browsing or searching. The final node follows the checkout action.
- the state diagram shows the state of a booking: it tells us what can happen depending depending on a state. Note also that the state may influence the booking object's behavior. Nothing can happen anymore once you've reach the attended state which leads to a final state.
Now to be honest the confusion between initial/final node ans state may also be related to their semantics, at least from a philosophical point of view: both types of diagram can be used to describe different aspects of the same behavior. In this case, having a token on an initial node could be seen as an initial state, and in the same way, the final state and the final node would both correspond to the end of the behavior.