A UML activity diagram answers:
Module 1.4 returns to activity diagrams because methods with parameters and Boolean decisions make process flow more important.
An activity diagram can represent:
The diagram communicates behavior at a higher level than source code. Its job is to make the flow understandable.
An activity diagram needs a clear place to begin reading.
The start node marks the entry point into the modeled process.
Conceptually:
The reader begins at the start node and follows the outgoing flow.
The start node does not perform work. It is not an action such as:
Create playeror:
Read parameterThe first action node after the start describes the first work that happens.
For example:
At this introductory level, use one obvious starting point unless the current design explicitly requires something more complex.
If an activity diagram models one method, the start node means:
It does not mean:
The meaning of the start depends on what the diagram is modeling.
The arrow direction matters. Flow moves away from the start node toward the first meaningful action.
An end node marks where the modeled activity is complete.
A simple activity might be:
The end node defines the conclusion of the activity being modeled.
If the diagram represents one method, reaching the end means that the modeled method-level activity is finished. It does not necessarily mean:
Ask:
The answer should be the activity currently being modeled.
Start and end nodes work together to make the scope of the process visible.
For example:
Everything between those nodes belongs to the activity being explained.
A method with one focused behavioral purpose can often be modeled with this same basic pattern:
As the behavior becomes more complex, the activity can contain additional actions and decisions between those boundaries.
A simple process can be pictured as:
The arrows show the direction of flow.
Read from the start node, follow each arrow, read each action in order, follow any decision path that applies, and continue until the activity reaches its end.
If the flow cannot be followed clearly from start to end, revise the diagram structure.
An activity diagram might say:
Update player availabilityThe C# implementation might involve a method parameter and a field assignment.
The diagram does not need to reproduce every C# token.
Its job is to communicate the logic of the process.
A process does not always follow one straight sequence.
For example:
A decision causes the process to follow a path based on a Boolean result.
The Decision Nodes in Activity Diagrams page develops that branching behavior in more detail.
A useful activity diagram shows enough detail for a reader to understand the behavior.
It should not become:
Use action wording that captures meaningful behavior at the current level of abstraction.
Before writing a method, an activity diagram can help you answer:
That makes the diagram a design tool rather than only documentation after the code exists.
Suppose a method already exists.
You can trace the method and model:
If the method includes a decision, the diagram can show the alternate flow without copying the source line by line.
This can make the logic easier to understand than reading source syntax alone.
An activity diagram focuses on:
A sequence diagram focuses on:
Both can describe behavior.
They emphasize different aspects of that behavior.
Methods now receive information from callers.
An activity diagram can show the behavior that uses that information.
For example:
The parameter belongs to the method design.
The activity diagram shows what the method does with the incoming information.