Activity Diagram in UML Activity diagrams represent the business and operational workflows of a system. An Activity diagram is a dynamic diagram that shows the activity and the event that causes the object to be in the particular state.
Elements of an Activity diagram Initial Activity: This shows the starting point or first activity of the flow. Denoted by a solid circle. This is similar to the notation used for Initial State. Activity: Represented by a rectangle with rounded (almost oval) edges. Decisions: Similar to flowcharts, a logic where a decision is to be made is depicted by a diamond, with the options written on either sides of the arrows emerging from the diamond, within box brackets. Signal: When an activity sends or receives a message, that activity is called a signal. Signals are of two types: Input signal (Message receiving activity) shown by a concave polygon and Output signal (Message sending activity) shown by a convex polygon.
Concurrent Activities: Some activities occur simultaneously or in parallel. Such activities are called concurrent activities. For example, listening to the lecturer and looking at the blackboard is a parallel activity. This is represented by a horizontal split (thick dark line) and the two concurrent activities next to each other, and the horizontal line again to show the end of the parallel activity.
Final Activity: The end of the Activity diagram is shown by a bull's eye symbol, also called as a final activity.
Creating an Activity Diagram Let us consider the example of attending a course lecture, at 8 am.
Figure 7.1—an example Activity diagram
UML state diagram / UML state machine Example UML State diagram. The UML state diagram is essentially a Harel statechart with standardized notation , which can describe many systems, from computer programs to business processes. The following are the basic notational elements that can be used to make up a diagram:
Filled circle, pointing to the initial state Hollow circle containing a smaller filled circle, indicating the final state (if any) Rounded rectangle, denoting a state. Top of the rectangle contains a name of the state. Can contain a horizontal line in the middle, below which the activities that are done in that state are indicated Arrow, denoting transition. The name of the event (if any) causing this transition labels the arrow body. A guard expression may be added before a "/" and enclosed in square-brackets (
eventName[guardExpression] ), denoting that this expression must be true for the transition to take place. If an action is performed during this transition, it is added to the label following a "/" ( eventName[guardExpression]/action ). Thick horizontal line with either x>1 lines entering and 1 line leaving or 1 line entering and x>1 lines leaving. These denote join/fork, respectively.
State diagrams versus flowcharts A state machine (panel (a)) performs actions in response to explicit events. In contrast, the flowchart (panel (b)) does not need explicit events but rather transitions from node to node in its graph automatically upon completion of activities. Activity diagrams are essentially elaborate flowcharts.