The basis of computer programming in any language begins with control flow.
Control flow (or flow of control) is the order function calls, instructions, and statements are executed or evaluate when any program is running.
Imagine that you would like to run an operation several times, until a condition is met. One option, is to rewrite the same code, while changing part of the syntax, that number of times you wish. Alternatively, we could write our code using control flow, and iterate through the same operation that will evaluate and stop until a certain condition is met. This last option usually implies in a much shorter, clearer and less complex form of writing code.
It is advantageous, for any programmer, to think in terms of in terms of control flow, and therefore have structured programs, because:
The complexity and time of the task at hand is greatly decreased;
A logical structure also means that the code has increased clarity;
It also facilitates collaboration, and therefore increases productivity.
There are many building blocks of control flow programming:
- Sequencing, which executes or evaluates something sequentially;
- Selection, which performs operations
ìfor unless certain conditions are met;
- Iteration, which
repeats an operation
fora determined number of times;
- Procedural abstraction, which involves a subroutine, nested call;
- Concurrency, which does several operations at the same time;
- Exception handling and speculation
- Non-determinism, which does an operation