Control Flow

The control flow is the path of execution through a program.

Related concepts:  SequenceConditionalLoop

Closest Wikipedia entry:  Control flow — In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an imperative programming language from a declarative programming language. Within an imperative programming language, a control flow statement is a statement that results in a choice being made as to which of two or more paths to follow.

Misconceptions about Control Flow
27 documented Misconceptions

Check Yourself
Misconception
CatchAlwaysExecutes
Catch blocks always get executed
Misconception
CatchProvidesOptions
Only the necessary part of a catch block executes
Misconception
ConditionOneOutEdge
A condition node in a control-flow graph can have a single outgoing edge
Misconception
ConditionalIsSequence
If-else is equivalent to sequence of two ifs
Misconception
DeferredReturn
A return statement in the middle of a method doesn't return immediately
Misconception
ElsIf
There is an elsif keyword for multi-way conditional statements
Misconception
ElseAlwaysExecutes
The else branch of an if-else statement always executes
Misconception
ForIsConditional
The body of a for statement executes at most once
Misconception
IfIsLoop
The body of an if statement executes repeatedly, as long as the condition holds
Misconception
IfRequiresElse
Every if statement requires an else
Misconception
InterproceduralEdge
In an intra-procedural control-flow graph, method call nodes point to the called method
Misconception
LoopTerminatingCondition
For and while loops end when the condition becomes true
Misconception
NoShortCircuit
&& and || always evaluate both operands
Misconception
PreIncrementBeforeLoop
Pre-increment in update part of for loop means increment before loop body
Misconception
RecursiveMethodNeedsIfElse
A recursive method needs to contain an if-else statement
Misconception
ReturnNoOutEdge
In a control-flow graph, a return statement has no outgoing edge
Misconception
StatementMultipleOutEdges
A non-condition node in a control-flow graph can have multiple outgoing edges
Misconception
TryCatchMandatory
If code could throw an exception, you must surround that code with a try/catch block
Misconception
TryFinishes
Exceptions get thrown at the end of the try block
Misconception
ZeroInEdges
A control-flow graph node (other than the entry node) can have zero incoming edges
Misconception
ZeroOutEdges
A control-flow graph node (other than the exit node) can have zero outgoing edges

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.