The activity diagram is a diagram type within the “Unified Modeling Language” (UML). This graphical modeling language defines forms for rep­re­sent­ing object-oriented pro­gram­ming. It specifies 14 diagram types. Certain forms are assigned to these. With the help of notation rules, systems and processes can be ab­stract­ed and clearly presented. UML models not only software systems, but also business processes. Activity diagrams are par­tic­u­lar­ly useful in both areas. But why should you create an activity diagram?

The purpose of activity diagrams

UML activity diagrams belong to the group of behavior diagrams in unified modeling language. While a structure diagram records the state of a system, i.e. the existing objects and their hi­er­ar­chies as well as con­nec­tions to each other at a certain point, behavior diagrams describe the chrono­log­i­cal flow of data streams. In addition to the activity diagram, the “use case diagram” and the “state machine diagram” belong to this group. Activity diagrams are similar in use and notation to flow­charts (es­pe­cial­ly program flow­charts), but are tailored to object-oriented pro­gram­ming.

Basically, it can be said that the activity diagram models the flow of ac­tiv­i­ties. These can be processes within a computer system, use case processes, or business processes. For example, the activity "preparing a cheese omelet" can be broken down into many small sub-ac­tiv­i­ties: the actions. These can take place chrono­log­i­cal­ly. One action would be "breaking eggs," followed by the action "whisking eggs while seasoning." The first action requires the second. They're in flux, so to speak.

Parallel processes can also be il­lus­trat­ed. If two people are in charge of preparing the omelet, this enables the actions to be carried out si­mul­ta­ne­ous­ly i.e. breaking eggs and chopping herbs. This means that the activity has two starting points. The people start their activity at these points and go from one action to the next. Although these two people play an important role in the activity diagram, they don’t have their own notation. You move from a starting point to an end point, crossing control or object flows to move from one action to the next. In between, there are oc­ca­sion­al barriers, so-called pins, which they only let things through under certain con­di­tions e.g. when both persons are present.

In the activity diagram, these “persons” are referred to as tokens. There are two types of tokens in the UML activity diagram: the first is the object token, which transmits in­for­ma­tion to the action node, starts an action there and (if specified) saves the result as a value. If the result and token cor­re­spond to the spec­i­fi­ca­tions defined in the pin, this output pin sends the object token via an object flow to the next action. Before the token can start this action, it must comply with the input pin spec­i­fi­ca­tions. Control tokens, on the other hand, only migrate over control flows and serve as markers. You start an action but do not transfer any data.

In the example described above (“preparing a cheese omelet”), we use the activity diagram to il­lus­trate the time sequence of a use case. Use case diagrams, on the other hand, il­lus­trate the system re­quire­ments that should be met for a use case.

UML 2 activity diagram don’t solely have to be used for everyday scenarios. First and foremost, they help you to il­lus­trate the processes in software systems in a struc­tured manner. This way, business analysts, for example, set guide­lines for software de­vel­op­ers. The experts exchange in­for­ma­tion about the graphic language on a generally un­der­stand­able and clear level. Once all processes have been settled and errors ironed out, the activity diagram serves as a clean template for pro­gram­ming.

If you integrate a suitable UML tool into your in­te­grat­ed de­vel­op­ment en­vi­ron­ment, the diagram can act as a code framework into a pro­gram­ming language using XML con­ver­sion.

The Object Man­age­ment Group (OMG), which specifies the UML, sum­ma­rizes the possible tasks of UML 2 activity diagrams.

  • Pro­ce­dur­al computer pro­gram­ming that assigns hi­er­ar­chies to ac­tiv­i­ties
  • In ob­jec­to­ri­ent­ed models, ac­tiv­i­ties act as methods that describe processes in more detail
  • For il­lus­tra­tion workflows and business processes
  • In com­put­er­based ap­pli­ca­tion systems, ac­tiv­i­ties specify processes at system level

The notations for UML activity diagrams

The forms within the UML can be un­der­stood as the building blocks of the language. So, the modeling language assigns meaning to each form. Modifying factors describe them in more detail and relate them to each other. In addition, shapes sometimes require certain other shapes or labels to create a mean­ing­ful diagram. Just as spoken language only makes sense if certain basic gram­mat­i­cal rules are observed, UML only functions as a means of com­mu­ni­ca­tion if you comply with the spec­i­fi­ca­tions.

UML 2.5 is the most current spec­i­fi­ca­tion of the modeling language, and so forms the basis of this pre­sen­ta­tion. UML defines the notation of the diagram types based on their ap­pli­ca­tion areas. Since the UML activity diagram il­lus­trates the flow of system processes and use cases, meta­mod­el­ing assigns ap­pro­pri­ate forms to it.

How are the in­di­vid­ual com­po­nents visually rep­re­sent­ed and which functions do the symbols in the UML activity diagram have?

Ac­tiv­i­ties

UML 2 specifies an activity as behavior that underlies sub­or­di­nate units (actions and objects) in an order. It uses data and control flow models to do this. The activity diagram can be displayed as part of a larger system in con­junc­tion with other diagram types. A large, rounded rectangle indicates the activity as a closed system (can also be omitted). Below in the example image, you can see the activity “cooking asparagus.” The title is written in the header of the large rectangle. The body ac­com­mo­dates edges (arrows) and nodes (rec­tan­gles). These symbolize the detailed actions, objects, and control or data flows of the activity.

Ac­tiv­i­ties are con­sid­ered classes in UML (their metaclass is the behavior). Therefore, they can be de­ter­mined more precisely by prop­er­ties. This can influence sub­or­di­nate elements. An activity is con­sid­ered completed when a token has moved from its starting point through the actions to the end point. The end point destroys the token. This also applies to all other tokens, so that the activity stops all syn­chro­nous actions.

Note

UML 1 defines activity diagrams dif­fer­ent­ly from UML 2; the earlier version assigned them the role of a spe­cial­ized state machine diagram, limiting their areas of ap­pli­ca­tion. So, if you are using a UML tool, you should make sure that it supports the desired for­mu­la­tion – ideally UML 2.5 or higher.

Actions: activity nodes that il­lus­trate the behavior

An action (ex­e­cutable node) is a model element that is hi­er­ar­chi­cal­ly sub­or­di­nate to the activity: the action is an instance of the class, “activity.” Actions represent behavior within a system. They are the basic building blocks for ex­press­ing behavior in UML. They are used both in activity diagrams and in in­ter­ac­tions.

When you create an activity diagram, use the notation “action” to display the ex­e­cutable subareas of an activity. In the example above, “peel the asparagus and put it in the pan” is a step further towards the com­ple­tion of “cooking asparagus.” Actions collect input in­for­ma­tion, process it, and produce output in­for­ma­tion. An action does not stop until it has been completed.

Within the UML activity diagrams, actions belong to the activity nodes. So-called edges (arrows) connect the actions with one another. UML dis­tin­guish­es between object flows (data flows) and control flows (trans­ports control token). Actions only process control flows. When data flows move between actions, pins (object nodes) accept the object tokens as input, convert them for pro­cess­ing the action, and then generate the object output, which moves on as object tokens.

Fact

The activity nodes category was in­tro­duced in UML 2. There are three subtypes: control nodes, object nodes, and ex­e­cutable nodes (the actions). There are no hi­er­ar­chies between these three. As long as they are not connected in series or defined in more detail within an activity group, they can be executed in any order (as soon as incoming tokens fulfil the con­di­tions set for a node) or in parallel.

Only if the con­di­tions set on the pins are met, will an action (input pin) be entered or will result (output pin). Even if an action has several incoming control flows, each in­di­vid­ual must offer a token before an action starts.

For actions within an activity diagram, the abstract syntax contains the simple form of the rounded rectangle. However, there are specific actions that modelers can use for more precise de­scrip­tions. Some of them are expressed in UML with their own notations. These are the subtypes of actions:

  1. Opaque actions act as place­hold­ers or are specified by concrete text syntax (not defined by UML).
  2. In­vo­ca­tion actions are actions that cause a certain behavior – directly or in­di­rect­ly. These include: 
  • Call actions: a call behavior action directly in­sti­gates a behavior. A call operation action, on the other hand, sends a request to an object that in­sti­gates a related behavior. The start object behavior action directly causes an object to execute its instance behavior. If none is defined, it can trigger the high­er­lev­el class behavior (clas­si­fi­er behavior).

    The notation of an action that causes behavior consists of a rounded rectangle. This is where you enter the name of the behavior you want to instigate. Call behavior actions are also marked with a trident icon, as shown in the picture below. This is to represent the further hi­er­ar­chi­cal branching that results from the action.
     
  • Send actions: Send actions in the activity diagram always send data asyn­chro­nous­ly (sequence diagrams also know syn­chro­nous messages, for example). This means that they do not wait for a response from the target object and don’t block the object flow. The action ends as soon as the message has been sent. So, it can have an “argument” input e.g. parameter, but does not produce a “result” output. In addition, messages can be sent to several re­cip­i­ents at the same time. Send signal action, broadcast signal action, and send object action belong to this type.

    Send signal actions differ in their notation from the usual form (the rounded rectangle). Instead, a pentagon points like a large arrow in the direction of the trans­mit­ted signal. If the content of a send object action also consists of a signal, you can use the same notation.
  1. Object actions change the state of objects (instances of a class). You can create or destroy them, compare them with other instances, read them, and then assign them to a class or change the clas­si­fi­ca­tion. The following instances of object actions then exist in UML 2:
  • “Create object actions” generate instances of a class i.e. objects
  • “Destroy object actions” destroy the object on your input pin
  • “Test identity actions” examine whether two values on your input pin represent the same object.
  • “Read self actions” determine their own context object.
  • “Value spec­i­fi­ca­tion actions” examine value spec­i­fi­ca­tions (the notation carries the label “value spec­i­fi­ca­tion”)
  • “Read extent actions” find all objects of a class and objects from its spec­i­fi­ca­tions (for practical reasons, modelers usually limit the range)
  • “Re­clas­si­fy object actions” change the class for the object on your input pin
  • “Read is clas­si­fied object actions” determine whether an object on your input pin belongs to a class
  • “Start clas­si­fi­er behavior actions” trigger a behavior for an object that is de­ter­mined by its class (the behavior is then asyn­chro­nous)
  1. Link actions change the behavior of as­so­ci­a­tions (re­la­tion­ships between clas­si­fiers, usually two classes) and their instances, like links. These include:
  • “Read link actions” retrieve values (link end data) on an as­so­ci­a­tion’s page
  • “Create link actions” are actions that create links (they do not have output pins because links are not data them­selves) and link objects
  • “Destroy link actions” delete links and link objects if they cor­re­spond to a specified link end data value
  1. Link object actions influence the behavior of link objects, but view the objects from different per­spec­tives. These are instances of link object actions:
  • “Read link object end actions” call up end objects from link objects
  • “Read link object end qualifier actions” call up clas­si­fiers end values from link objects
  • “Create link object actions” are special link actions that are used to create link objects
  1. Struc­tur­al feature actions determine the behavior of struc­tur­al char­ac­ter­is­tics in activity diagrams. To do this, they require an input pin, since they are usually assigned both an object and a sta­t­i­cal­ly specified struc­tur­al char­ac­ter­is­tic of a clas­si­fi­er. The structure char­ac­ter­is­tic action affects both elements. The following types are available:
  • “Read struc­tur­al feature action” reads the values of the structure char­ac­ter­is­tics and forwards them as output
  • “Add struc­tur­al feature value actions” require a value input pin which specifies the value that the action assigns to a struc­tur­al feature
  • “Remove struc­tur­al feature value actions” subtract a value from a struc­tur­al feature (a value input pin with mul­ti­plic­i­ty of 1. 1 specifies this value)
  1. Variable actions influence sta­t­i­cal­ly specified variables defined by an activity or struc­tured activity node. There are three types:
  • “Add variable value actions” also require a value input pin, but must be of the same type as the variable and adds exactly one value to it
  • “Remove variable value actions” remove a value specified by the pin
  • “Clear variable actions” remove all values of a variable
  1. Accept event actions belong to the so-called wait points. This means that the action is waiting for an event from the event pool of the context object. The action has triggers that set off the action when one or more pre­scribed states occur. UML describes three spe­cial­iza­tions:
  • “Accept call actions” have a trigger that accepts call events: two result output pins and a return in­for­ma­tion output pin complete the arrange­ment (if a reply action is to be executed, store the necessary in­for­ma­tion in the return in­for­ma­tion output pin)
  • “Reply actions” have a con­nec­tion to the accept call actions: On the one hand, the triggers should match so that the response action can react to the pre­vi­ous­ly executed call ac­cep­tance action in the case of a call event, on the other hand, the high­er­lev­el behavior places its output value in the return in­for­ma­tion input pin of the reply action
  • “Un­mar­shall actions” query the values of object struc­tur­al features (to recognize the object, they have an object input pin; the values obtained are issued on an output pin)
Fact

If struc­tured data of an object or el­e­men­tary data of a program has to be trans­ferred to other programs or program sections, or if you want to save it, you have to convert it into a suitable format. This process is called mar­shalling. The opposite process, un­mar­shalling, converts this “frozen” data back into ex­e­cutable objects. An example of this is the transfer of UML diagrams from one tool to another program using XML con­ver­sion.

  1. Struc­tured actions declare UML 2 in the activity diagram both as actions and as an activity group (see above). This means, on the one hand, that their behavior is de­ter­mined by activity nodes and edges, and on the other hand, that certain subtypes of these actions stipulate a certain behavior for the ex­e­cutable nodes due to their semantics – es­pe­cial­ly with regard to their sequence.

These are the subtypes of struc­tured actions:

  • Con­di­tion­al nodes consist of one or more clauses that represent the different branches of the possible ex­e­cutable actions. A clause contains a test segment and a body segment, which in turn contain cutquan­ti­ty-free ex­e­cutable nodes. First, the clause executes the action in the test area. If its output value is “true,” the clause executes the action in the body area.
  • Loop nodes describe a group of actions that are repeated within a loop. The actions are divided into three sections: “setup,” “test,” and “body.” The loop always executes the “setup” first. This is followed by “test” or “body,” which is then repeated al­ter­nate­ly.
  • Sequence nodes impose an order on the ex­e­cutable node within their limits. You display these with data flows as activity edges (i.e. simple arrows). Edges can point freely into and out of the structure.
  1. Expansion regions are another form of struc­tured activity nodes. You accept one or more col­lec­tions of values as input. On its way to the expansion region, the input pin copies each incoming token to the number of col­lec­tion elements. All inlying nodes process them­selves at each in­di­vid­ual value of the col­lec­tion. A run is con­sid­ered an “expansion execution.” An expansion node (a type of object node) indicates the interface of the expansion region. On the outside, they display their values as a col­lec­tion, on the inside, the in­di­vid­ual elements of the col­lec­tion are con­sid­ered as values. Draw a rounded rectangle with a dotted line for the notation. The expansion nodes appear as rec­tan­gles with segments and, as shown below, are drawn directly on the line. The seg­men­ta­tion should represent the list of value col­lec­tions.
  1. Reduce actions call up a behavior until a single value emerges from a col­lec­tion of values. To do this, the action combines the col­lec­tion elements. The action therefore has two “in” pa­ra­me­ters, but only one “out” or “return” parameter.
     
  2. Raise exception actions (actions that cause an exception) terminate them­selves as soon as they cause an exception. Therefore, they do not terminate like normal actions that stop when the action is finished. They spread outwards through the system to the next higher struc­tured activity node. If it has a handler that cor­re­sponds with the exception, it stops the action. Otherwise, it will spread further.

Object nodes: activity nodes that control object tokens

Object nodes are subtypes of activity nodes. In general, an object in UML is the smallest instance with values. In the activity diagram, objects represent data. While an action is being executed, the object nodes hold this data. Because only control tokens can go directly through an action. Object tokens, on the other hand, are received as a value for an input pin and are forwarded by the output pin on the object flow.

Object nodes were first in­tro­duced in the UML 2 activity diagram. They are typed elements. If an object node cor­re­sponds to a certain type, the object tokens that move on it must have cor­re­spond­ing values. An exception are null tokens that manage without a value – they conform to each object node.

Object nodes dictate the sequence in which tokens leave them. There are four ways to do this:

  • Unordered (not specified)
  • Ordered (behavior defined by the modeler)
  • FIFO (first in first out): the order of entry and exit remains the same
  • LIFO (last in first out): the order is exactly the opposite

If you want to create an activity diagram, you have four types of object nodes to choose from for modeling:

  1. The pin: Pins have already been cut in this version. In the first graphic, the basic notation of pins is shown. Due to their function as a link between action flows and object flows, modelers usually draw them as small rec­tan­gles directly on the action symbol. Input pins are marked with an arrow (i.e. an edge or an object flow) in the direction of the action. For output pins, the arrow leads away from the action. The following graphic shows how you can shorten pins of the same type (left) or how you can draw input and output pins if you omit the edges (right).
  1. Activity parameter node: The activity belongs to the metaclass of the be­hav­ioral de­scrip­tion. According to UML, each behavior has pa­ra­me­ters. Before a behavior is executed, you can feed values into it for pro­cess­ing. New values are returned after pro­cess­ing. The pa­ra­me­ters in this structure are the place­hold­ers that allow these values to be entered or issued. The activity parameter node performs this task for the UML activity diagram. This means that activity parameter nodes are at the beginning and end of an activity.

    As a result, nodes like these either have only incoming or only outgoing activity edges. Input activity parameter nodes are drawn with outgoing edges, and output activity parameter nodes with incoming edges. There is one activity parameter node for each parameter, both of which have the same type.
  1. Buffer nodes: Similar to pins, the buffer node (central buffer node) is used directly in the activity diagram. This object node stores or buffers values anywhere in the diagram. In contrast to the pin, however, it stands on its own without being bound to an activity node. The buffer node uses the object flow to connect incoming and outgoing objects with other object nodes e.g. with a pin.
    As with all object nodes, the data storage node is displayed as a rectangle. To dif­fer­en­ti­ate, write the stereo­type “<<datastore>>” in the header.
    The buffer node is used to buffer incoming and outgoing object flows. It accepts all incoming object tokens and makes them available for outgoing object flows. Only when an object node becomes free at the other end of the flow and accepts the object pa­ra­me­ters, will the token get forwarded. According to UML notation, this mode consists of a simple rectangle. You can display its special functions with the stereo­type “<<cen­tral­Buffer>>.”
  1. Data storage node: Like buffer nodes, you switch data storage nodes between object flows without binding them to an action. This subtype of buffer nodes has a special feature: It stores a copy of each token sent until the higher-level activity is completed. However, each value exists only once on the data storage node. If the node already stores an object token with a fixed identity, it does not accept any new tokens with exactly the same prop­er­ties.

Control nodes

Within a UML activity diagram, tokens move through various actions until the activity is completed by the first token arriving at the end node. Since several tokens can pass through this process at the same time, a certain order is required. Use control nodes to ensure a clear process flow. These only manage control flows along your path from the beginning of the activity diagram through the actions to the end of the activity. Control nodes cannot cache tokens, unlike object nodes such as the buffer node.

A sig­nif­i­cant dif­fer­ence between object and control flows is that only control tokens migrate on control flows. Unlike object tokens, these tokens do not carry any data. They are merely markers. So, actions do not require object nodes (es­pe­cial­ly pins) to accept and pass on control tokens. A control token starts an action, moves to the next one and then sets it in motion. It controls the chrono­log­i­cal execution of the activity.

Among the UML activity diagram symbols, the control nodes are probably the most diverse. They belong to the activity nodes. Here are six types of UML 2:

  1. Start nodes (initial nodes) start an activity. When an activity starts, the start node im­me­di­ate­ly sets the control flow in motion. If several start nodes exist, the re­spec­tive control flows start si­mul­ta­ne­ous­ly. Struc­tured activity nodes can also have start nodes. These also start im­me­di­ate­ly when the struc­tured activity is ini­tial­ized, as long as no con­di­tions for the start have been set. Since initial nodes are at the beginning, all their edges are outgoing activity edges. These are always control flaws.

    Another special feature of starting nodes: The control tokens placed on the start node at the beginning of an activity can stay there if the control flow does not accept the offered token or is blocked.
     
  2. End nodes end the flow of an activity. There are two types of end nodes: The activity final node ends the entire activity by de­stroy­ing all tokens within the activity when the first token arrives. Only object tokens in the output of activity parameter nodes are retained. It also stops all syn­chro­nous actions. Asyn­chro­nous actions run until they are completed. End nodes accept all incoming tokens. Unlike the start node, an end node only has incoming activity edges. More than one end node is possible.
    If you draw an activity diagram with more than one end node, actions might possibly stop before they have served their purpose, because a token has already reached the first end point. The flow final node stops a control flow and destroys all incoming tokens. This does not affect other control flows. This end node is a practical al­ter­na­tive if you model several end points in the activity diagram.
  1. Par­al­leliza­tion nodes and syn­chro­niza­tion nodes (fork nodes and join nodes), also called forms, are control nodes with almost identical notations that mirror their tasks. A par­al­leliza­tion node divides an incoming activity edge into several, si­mul­ta­ne­ous­ly outgoing flows. Only one activity edge can enter the par­al­leliza­tion nodes. If it is a control flow, all outgoing edges are also control flows; the same principle applies to object flows. The node creates copies of the incoming token for all outgoing flows. If a token is accepted at the des­ti­na­tion of the outgoing flow, the token is deleted from the source node. If another target does not accept its token, the par­al­leliza­tion node can stop the token until it is accepted

Syn­chro­niza­tion nodes work exactly the other way round. Several edges run into them, but only one edge runs out. If all of the incoming edges consist of control flows, this is how a control flow leaves the node. If there is only one object flow below it, UML specifies the outgoing edge as the object flow. If control tokens are also received in this case, they expire and only object tokens run out. If two objects have the same identity, the node merges them into one token. Generally, tokens only run out when all incoming edges offer one (“and” operation). This takes place under the “first in first out” principle. If you assign a value spec­i­fi­ca­tion to the syn­chro­niza­tion node using “joinSpec,” the node waits for tokens that ex­plic­it­ly fulfill these re­quire­ments before issuing tokens.

  1. Branching nodes and con­nect­ing nodes (decision nodes and merge nodes) also share the same symbol in the activity diagram. The flow control is one of the dis­tin­guish­ing features of these node notations. A branching node requires at least one, or two incoming edges at the most. UML names one the “primary incoming edge” and the second is called “decision input flow.” Whether outgoing flows represent object or control flows depends on the type of primary edge. The task of the node is to choose between outgoing edges. The node offers its inbound node without copying it. So the token can only take one way.

A con­nec­tion node bundles several incoming flows into a single outgoing flow. Unlike the syn­chro­niza­tion node, the con­nec­tion node does not merge tokens into a new one or syn­chro­nize the types of incoming edges. So, for an outgoing control flow, all incoming edges must also be control flows. The same applies to object flows. The con­nec­tion node simply offers all incoming tokens for the outgoing edge.

Summary

If you want to create an activity diagram in UML and edit the concept in a team, it is important to adhere to the notation. This is the only way to ensure the general com­pre­hen­si­bil­i­ty of this graphical modeling language. In this article, we have in­tro­duced the most important activity nodes and edges with their functions. We have also presented all basic and specific notations for activity diagrams according to UML 2.5.1 spec­i­fi­ca­tion. The ex­haus­tive­ly explained spec­i­fi­ca­tion of all UMP activity diagram icons can be found on the Object Man­age­ment Group website.

Go to Main Menu