UML State machine diagram and activity diagram are both behavioral diagrams but have different emphases. Activity diagram is flow of functions without trigger (event) mechanism, state machine is consist of triggered states.
Example: State diagrams versus flowcharts
People often confuse state diagrams with flowcharts. The figure below shows a comparison of a state diagram with a flowchart. A state machine diagram in the Figure on the left below performs actions in response to explicit events. In contrast, the Activity diagram in the Figure of the right below does not need explicit events but rather transitions from node to node in its graph automatically upon completion of activities.
What is State Diagram?
A state diagram (also called state machine diagram, statchart and start transition diagram) is a type of diagram behavior diagram in UML. In most OO techniques, state diagrams are drawn for a single class to show the lifetime behavior of a single object. They describe all of the possible states that a particular object (or even the entire system) can get into. State Machines give us the means to control decisions and each state is like a 'mode of operation' for the object which behaves differently depending on its state.
What is Activity Diagram?
Activity diagrams describe activities which involve concurrency and synchronization, which are a variation of state diagrams that focuses on the flow of actions and events. They can be used for:
- To model a human task (a business process, for instance).
- To describe a system function that is represented by a use case.
- In operation specifications, to describe the logic of an operation.
Activity Diagram vs State Machine Diagram
In UML semantics, Activity Diagrams are reducible to State Machines with some additional notations that the vertices represent the carrying out of an activity and the edges represent the transition on the completion of one collection of activities to the commencement of a new collection of activities. Activity Diagrams capture high level activities aspects. In particular, it is possible to represent concurrency and coordination in Activity Diagrams.
Take a look at the Activity Diagram which models the flow of actions for an incident. Such an Activity Diagram focuses on the flow of data within a system.
State Machine Diagram
In State Machines the vertices represent states of an object in a class and edges represent occurrences of events. The additional notations capture how activities are coordinated. Objects have behaviors and states. The state of an object depends on its current activity or condition. A State Machine Diagrams shows the possible states of the object and the transitions that cause a change in state.
Take a look at the State Machine Diagram below. It models the transitioning of states for an incident. Such a state diagram focuses on a set of attributes of a single abstraction (object, system).