Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
roth_stephan_clean_c20_sustainable_software_development_patt.pdf
Скачиваний:
29
Добавлен:
27.03.2023
Размер:
7.26 Mб
Скачать

Appendix A Small UML Guide

Behavioral Modeling

In addition to modeling static structures, UML also offers various possibilities to model the behavior of software, i.e. dynamic aspects and processes during the operation of the software. The three diagram types most commonly used for this purpose are activity diagrams, sequence diagrams, and state diagrams.

Since the total vocabulary range of UML is also relatively large, we will confine ourselves in this small introduction only to the elements that are necessary for understanding the behavioral diagrams presented in this book.

Activity Diagram

An activity diagram is suitable for describing complex processes (e.g., procedures, operations, etc.). The paths through the process described by an activity diagram can be divided and reunited, decisions can be made, and parallel regions may also exist, i.e. you can also describe concurrently running processes.

In general, an activity diagram consists of nodes and edges. The edges determine the processing order. The nodes are the elements that are brought into a certain order by the edges.

Figure A-14 depicts a simple example of an activity diagram. It shows that there are two alternative flows for regular customers and new customers, because regular customers already have a customer account, whereas new customers first have to

provide their data and then their credit card is charged. The diagram also shows that for regular customers, debiting the customer account and crediting the bonus points can run in parallel.

466

Appendix A Small UML Guide

Figure A-14.  An activity diagram that depicts the process of purchasing products

Action

A very central element in activity diagrams is an executable node that is called action.

ACTION

An action is the fundamental unit of executable functionality.

467

Appendix A Small UML Guide

Actions are used to describe that something is happening in the modeled system, i.e. some kind of function or processing. The syntax (notation) of an action is a rectangle with rounded corners, as depicted in Figure A-15. The name of the action is usually the description of what is executed. Good and well-understandable action names consist of a noun and a verb.

Figure A-15.  The notation of a simple action

There are many special kinds of actions in UML. For our purposes, the simple standard action (also called an opaque action), which describes by an expressive name what happens within the modeled system, is sufficient.

Control Flow Edge

In Figure A-16, the solid line with an open arrowhead connecting the action called “Fill shopping cart” to “Identify customer” is a control flow edge. This means that when the “Fill shopping cart” behavior is completed, control is passed to the action named “Identify customer”.

Figure A-16.  A control flow edge connects two actions

A control flow edge can also have a so-called guard. Guards can be used, for example, to decide how a process in an activity will continue. A guard is depicted by a condition, which is a (Boolean) expression that can be evaluated to true or false, surrounded with square brackets, e.g., [is regular customer].

Other Activity Nodes

Table A-3 provides an overview with brief descriptions of the other nodes that can be seen in the activity diagram in Figure A-14.

468