Flowcharts Lost and Regained
Do you remember flowcharts? Flowcharts were/are a crucial tool in developing the flow of the logic in a structured program, process, an algorithm, etc. I remember how excited I was when I bought my first green plastic flowchart template. Some of my flowcharts were pages long but the process of flowcharting always clarified my logic .
Those green templates can still be bought in office supply stores in the section with drafting tables and blue drafting engineering pencil sets.
Although we have drafting and flowcharting software, unfortunately, flowcharting (which was taught in every Programming 101 course years ago) is a lost art to many beginner programming students.
Now we have parallel algorithms and even more so we need that logic clarified. Well, the advantages of flowcharting is now regained in the UML activity diagram with new symbols, and more flow to accommodate concurrency. The activity diagram is a flowchart showing the sequential and concurrent actions or activities amongst objects used in a use case, a process or to reflect their state.
It is comprised of decision branches, starts, stops, and synchronization bars that join or fork several actions or activities. To represent an action or activity state, the UML uses the standard flowchart symbol used to show the enter and exit point of the flowchart. This symbol is used regardless of the type of action or activity occurring.
Like flowcharts, activity diagrams have a decision symbol. The outbound transitions are guarded conditions, simple boolean expressions, that determine the path of the flow of control. Unlike a flowchart, the UML defines a symbol that can be used to represent the instant where multiple flows of controls occur concurrently. A synchronization bar, a thick horizontal line, is used to show where a single path forks into parallel paths and where parallel paths join. There can be multiple outbound transitions (forking) or multiple inbound transitions (joining) where each transition represents a different path. Forking means multiple flows of control will occur and joining means multiple flows of control need to be synchronized.
Also, unlike flowcharts, the diagram can be divided into separate sections called swimlanes. Each swimlane represents a particular object, component, or use case and their actions or activities. Swimlanes are vertical lines that partition the diagram into sections. An action or activity can only occur in a single swimlane but transitions and synchronization bars can cross one or more swimlanes. Actions or activities in the same lane or different lanes but at the same level are concurrent.
Figure 2 courtesy "Professional Multicore Programming: Design and Implementation for C++ Developers" Hughes & Hughes 2008
The expression of concurrency seems sufficient for a manageable number of paths or threads. But what about massive parallelism, how would that be expressed? We will leave that to a future blog.
Flowcharts lost and regained for parallel activites may not rise to the level of the visualization of quantum theory but this technique and others that allow us to "visualize the model" gives us new insight and understanding of complicated processes and structures.