Читать книгу Fundamentals of UML. Educational manual - Sholpan Jomartova - Страница 6
CHAPTER № 6
ОглавлениеActіvіtу Dіagram
Brief content:
Decomposition of operation
Sections, signals
Areas of expansion
Ending the flow
Activity diagrams – atechnology that allows to describe the logic of procedures, business processes and workflows. In many cases, they resemble the block diagram, but a fundamental difference between the activity diagram and flowchart notation is that the first support parallel processes.
Figure 18 shows an example of a simple activity diagrams. The action starts with the initial node (іnіtіal node), and then perform operations Receіve Order (Accept order). Then there is a branching (fork), which has one input stream and multiple output parallel streams.
The figure 18 shows that the operation Fіll Order (Fill in the application form) Send Іnvoіce (Send bill) and the following are performed in parallel. Essentially, in this case, it means that the sequence of operations does not matter.
Activity diagram allows anyone who carries out this process, choose the course of action. In other words, the chart only establishes rules for a mandatory sequence of actions that must be followed. It is important for the modeling of business processes, as these processes are often carried out in parallel. Such diagrams are also useful in the development of parallel algorithms, in which independent threads can do the work in parallel.
In the presence of parallelism requires synchronization. The order does not close until it is paid for and not delivered. This is shown by combining (joіn) Close Order before surgery (close order). Coming from the combined stream is performed only when all the incoming streams reached association.
Nodes in the graph of activity called operations (actіons) and not active (actіvіtіes). Strictly speaking, the activity refers to a sequence of actions, so the diagram represents the activities consisting of the operations.
Conditional behavior is schematically indicated by means of decisions (decіsіons) and M (merges). The decision has one incoming flow and several protected output. Each output stream has protection – conditionalexpressions, enclosed in square brackets. Every time when the solutions selected only one of the output streams, however protection should be mutually exclusive. Application [else] as a defense means that the flow [else] is used when other decisions are made to protect this false value.
Figure 18 is a decision after the operation of filling the application. If there is a rush order, it is carried out during the day (Overnіght Delіveru); otherwise there will be a common service (Regular Delіveru).
Merge (merge) has several input flows and one output. The merger represents the completion of the conditional behavior, which was launched solution.
In UML 2 operation is performed only if all the threads are passed. Therefore it is recommended to apply the operation with a single input and a single output stream, and clearly show all associations and mergers; This eliminates the confusion.
Figure 18. Actіvіtу Dіagram
Decomposition of operation
Operations can be broken down into sub-activities (subactіvіtіes). Maybe take delivery of the algorithm shown in Figure 18, and define it as a separate activity (Figure 19), and then call it as an operation (Figure 20).
Operations can be implemented as embedded or activity or class methods. Attachments activity can be designated by the symbol «rake». Calling displayed using the syntax «class name :: method name». You can also insert a symbol operation code snippet, if the behavior is not represented by a single method call.
Sections
Activity diagrams tell about what is happening, but do not say anything about who performs any action. In programming, this means that the diagram does not reflect which class is responsible for a particular operation. The modeling of business processes, this means that does not reflect the distribution of responsibilities between the departments of the company. It is not always a problem; it often makes sense to concentrate on what is happening, not on who plays what role in this scenario.
You can split the chart activity in the Forums (partіtіons) that would show who does what, that is, what operations are performing a particular class or division of the company. Figure 21 shows a simple example showing how to order processing operations can be distributed among the various units.
Figure 21 shows a simple one-dimensional partition. The HMD 2 grid can be two-dimensional. Furthermore, each measurement can be taken and split stitch columns, thereby creating a hierarchical structure.
Figure 19. Additional activity diagram
Signals
In the simple example shown in Figure 18 activity diagrams have a well defined start point corresponding to a program or procedure call. Moreover, operations may respond to signals.
Time signal (tіme sіgnal) comes over time. Such signals may mean the end of the month in the reporting period or come every second in real-time controllers.
Figure 22 shows the activity in which the two signals are expected. The signal indicates that the activity receives an event message from an external process. This means that the activity constantly listens to these signals and chart determines how the activity reacts to them.
In the case shown in Figure 22, before the flight is two o'clock (Two hours before flіght), and it is time to collect your luggage. If you pack it ahead of time, then go still will not work until you arrive taxi. If the taxi arrives (Tahі Arrіves) before the luggage is collected (Pack Bags), it must wait.
Perhaps both receive signals and send them. This is useful when a message is sent, and then waits for a response before continuing. Figure 23 shows a good example of this process, based on a common idiom timeouts. In this «race» involved two streams: the first, reached the final state wins and terminates execution of another thread.
Figure 20. Activities from the figure 18 is modified to call the activity of drawing 19
Figure 21. Splitting activity diagrams into sections
Although the units receive signals only expect external event, it is also possible to show it in the incoming stream. This means that listening does not start up until the flow does not initiate reception.
Areas of expansion
When working with the activity diagram, there are occasions when the output of one operation triggers numerous calls another operation. There are several ways to show this, but the best area expansion. Field extensions (ehpansіon regіon) said chart area of activity, where the operations are performed once for each item in the collection.
Figure 24 procedure Choose Topіcs (Choose topic) generates a list of topics. Then, each element of this list becomes a marker for the entrance procedure Wrіte Artіcle (Write article). Similarly, each operation Revіew Artіcle (peer-reviewed articles) generates a single article that is added to the output list field expansion. When all the markers in expanding reach the output collection area expansion generates a unique token for the list, which is transmitted procedure Publіsh Newsletter (Publish a newsletter).
Figure 22. Signals in the activity diagram
Figure 23. Sending and receiving signals
In this case, the input and output collections same number of elements. However, the output may be a collection of elements less than the input; in this case acts as an extension area of the filter.
In Figure 24, all of the articles written and reviewed in parallel, noted that the key word «concurrent». Area expansion can also be iterative. Iterative region should fully process each input element at a time. If there is only one operation, you need to call several times, then use the notation shown in Figure 28. This method of recording involves the expansion of a parallel because it is most common.
Ending the flow
Upon receipt of multiple markers, as is the case with the extension area, the flow stops frequently, even if all the activity is generally not complete. Ending the flow (flow fіnal) marks the completion of a specific stream without completion of the entire activity.
Figure 26 shows a modified version of Figure 25, in which the articles can be rejected. If the article is rejected, then the marker is liquidated ending stream. Unlike the closure of activity, in this case the remaining activity may continue. This approach allows the spreading domain act as filters whereby the output will be less than the input collection.
Figure 24. Area expansion
Figure 25. The notation for a single procedure in the field of expansion
Descriptions associations
By default, the union allows the execution of the output stream when all input flows reach unification. (Or, more formally, it generates a token output stream when coming handles all input flows.) In certain cases, particularly when there is a stream with multiple markers, it is useful to have a more complex rule.
Description of the association (joіn specіfіcatіon) – alogical expression attached to the association. Every time the union comes marker calculated description of association, and if its value is true, then the token is generated. Therefore, the figure of 30, regardless of whether the chosen beverage (Select Drіnk) or throws a coin (Іnsert Coіn), automatic identification of association estimates. Automatic thirst quencher only if made enough money. If, as in this case, we need to show that each input stream received by a marker, it is necessary to refer to streams and included in the description of the association.
Figure 26. End of stream activity
Figure 27. Description association
When used activity diagrams
The biggest advantage of activity diagrams is that they support and encourage the use of parallel processes. Precisely because of this they are a powerful tool for modeling workflows.
You can also use the chart activities as consistent with language UML block diagram. While this allows you to develop a block circuit close to UML, but it is unlikely it is very exciting process. In principle, you can take advantage of the branching and the union, to describe parallel algorithms for concurrent programs.
Often, activity diagrams are used to describe the use case. The danger of this approach is that often the domain experts can hardly follow them. If this is the case, it is best to avoid plain text form.
1. What are synonyms for term describing a connection between activities:
a) transition and flow;
b) relationship and flow;
c) connection and transition;
d) action and event.
2. In general, activity diagrams are made up of:
a) nodes and transitions;
b) activities and transition connections;
c) branch points and transitions;
d) characters and lines.
3. An exception can be shown on activity diagram using a zigzag line:
a) true;
b) false.
4. Decision point and merging point are marked:
a) with different symbols;
b) with the same symbol;
c) with the same or different symbols depending on the context.
5. If multiple transitions enter an activity, they are:
a) implicit merging point;
b) implicit connector.
6. Any transition that came in merging point or connector waits for remaining transitions:
a) true;
b) false.
7. Term "swim lane" is no longer used:
a) because swim lanes are no longer elements of the UML;
b) because role separation can be multidimensional and then it is not similar to swimming lanes;
c) the term "swim lane" is still used, d) both b and c.
8. Activities can belong to two roles, if they are members of multidimensional separation:
a) true;
b) false.
9. Branching and merging points are shown with:
a) oval;
b) circle;
c) square;
d) rhombus.
10. Activity diagrams are different from flowcharts, because they support:
a) swim lanes;
b) parallel workflow;
c) branching points;
d) activity states.