​

DRAKON-Erlang: Visual Functional Programming

Home|Download

By Stepan Mitkin

Part 6 of 10

Previous|Contents|Next

Silhouette

Primitive and silhouette

DRAKON has two types of diagrams:

  1. The diagrams that have been introduced before are called primitives. Primitives are good for very basic algorithms and for educational purposes.
  2. The full power of DRAKON, however, comes with another type of diagrams. That type is called silhouette.

Silhouette is the recommended way of drawing diagrams with DRAKON.

Branches

Silhouette combines several simple diagrams to build a complex one. The goal is to partition a big algorithm into logical parts. These parts are called "branches".

Each branch has a name. A branch ends with an "Address" icon that points to the next branch. The rightmost branch has an "End" icon instead of an "Address" at the bottom. There can be only one "End" in an algorithm.

Silhouette

The header of the diagram

Silhouette answers the three questions of the king:

  1. What is the name of the task?
  2. Which parts does the task consist of?
  3. What are the names of the parts?

The "Header" icon contains the name of the diagram and answers the first question.

The branches answer the second question.

The headers of the branches give the answer to the third question.

The diagram name is always located in the upper-left corner of the diagram. The branch headers are just under the diagram name. They are aligned to form a horizontal line.

This convention allows the reader to grasp the general ideas of the algorithm without delving into the details.

The order of branches

Theoretically, the branches could follow each other in any order. The next branch to execute is determined by the name inside the "Address" icon of the previous branch.

Nevertheless, DRAKON rules recommend to arrange the branches left-to-right. The leftmost branch should be the first one. The rightmost branch should be the last one. The branches in between should be sorted in such a way that the next branch should always be to the right from the current one. Some branches can be skipped.

Silhouette: order of branches

In procedural languages, it is possible to jump back to a branch which is to the left from the current branch. This is especially convenient for programming of finite automata.

DRAKON's silhouette is a very good way of representing a state machine:

  • Each branch becomes a state.
  • The "Address" icons define the allowed state transitions.

But functional languages usually do not have loops. Therefore jumping left on a DRAKON-Erlang silhouette is not allowed.

Sorting "Address" icons

When a branch has several "Address" icons, it is recommended to sort them so that they appear in the same order as the branches they point to. This guideline should not apply when such ordering breaks "The further to the right ⎯ the worse" rule. Routing the happy path through the main vertical and moving the error handling to the right is more important.

A silhouette that implements the quicksort algorithm:

The main verticals of the branches constitute the happy path of the whole silhouette. The reader may follow only the main verticals if he is not interested in the processing of error situations.

Do not connect the branches

Rule: never connect two branches of a silhouette.

Twin error

The connecting lines

The lines and the arrow that surround the branches in a silhouette are technically not necessary. But their presense gives the diagram a connected and finished look. The diagram is perceived not as a disjoint set of parts, but as a whole picture that has a meaning.

Previous|Contents|Next


Contact: drakon.editor@gmail.com