Activity diagrams subsume data flow diagrams, flowcharts, finite state machines, and Petri-nets.
We can use an activity diagram to model the process/activity/workflow executed by a system (organization, hardware, software, etc.), use case (function), component (object), protocol, etc. This is called the context of the activity.
An activity is a function with an associated context (resources) and actor (processor, agent). The actor performs or executes the activity. The activity may have an input, it may process that input, and it may produce an output.
An activity diagram is a directed graph. There are several types of nodes:
Actions
Data
�� Objects
�� Parameters
Control
�� Start
�� Final
����� End Activity
����� End Flow
�� Branch/Merge
�� Fork/Join
Tokens representing data/information, resources/objects, and/or control flow from node to node following paths indicated by the arrows connecting the nodes.
// converts Farhenheit to centigrade
void temperatureConverter() {
�� do {
����� Temperature fDegrees =
enterTemperature();
����� if (invalid(fDegrees)) {
�������� reportError();
�������� break;
����� }
����� Temperature cDegrees = 5 * (fDegrees
- 32)/9;
����� display(cDegrees);
�� } while(true);
�� display("bye");
}
abstract class Action {
�� Actor processor;
�� abstract Object execute(Object input,
Classifier context);
}
abstract class Branch extends Action {
�� Action concequence, alternative;
�� abstract boolean condition(Object
input, Classifier context);
�� Object execute(Object input, Classifier
context) {
����� if (condition(input, context)) {
�������� return consequence.execute(input,
context);
����� } else {
�������� return alternative.execute(input,
context);
����� }
�� }
}
class Activity {
�� List<Action> actions;
�� Object execute(Object input, Classifier
context) {
�����
�� }
}
�����
��
��