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
34 documented Misconceptions

Check Yourself
Misconception
CatchAlwaysExecutesJava
Catch blocks always get executed
Misconception
CatchProvidesOptionsJava
Only the necessary part of a catch block executes
Misconception
ConditionOneOutEdgeJava
A condition node in a control-flow graph can have a single outgoing edge
Misconception
ConditionalIsSequenceJava
If-else is equivalent to sequence of two ifs
Misconception
ConditionalIsSequencePython
If-else is equivalent to sequence of two ifs
Misconception
ConditionalIsSequenceScratch
If-then-else block is equivalent to sequence of two if-then blocks
Misconception
ConditionalOperatorNotExpressionJavaScript
The conditional operator is not an expression
Misconception
DeferredReturnJava
A return statement in the middle of a method doesn't return immediately
Misconception
DeferredReturnPython
A return statement in the middle of a function doesn't return immediately
Misconception
ElsIfJava
There is an elsif keyword for multi-way conditional statements
Misconception
ElseAlwaysExecutesJava
The else branch of an if-else statement always executes
Misconception
ElseAlwaysExecutesScratch
The else branch of an if-then-else block always executes
Misconception
ForIsConditionalJava
The body of a for statement executes at most once
Misconception
IfIsLoopJava
The body of an if statement executes repeatedly, as long as the condition holds
Misconception
IfIsLoopPython
The body of an if-statement executes repeatedly, as long as the condition holds
Misconception
IfRequiresElseJava
Every if statement requires an else
Misconception
InterproceduralEdgeJava
In an intra-procedural control-flow graph, method call nodes point to the called method
Misconception
LoopTerminatingConditionJava
For and while loops end when the condition becomes true
Misconception
MissingElseTerminatesScratch
Blocks following an if without else will not execute if the condition is false
Misconception
NoShortCircuitJava
&& and || always evaluate both operands
Misconception
NoShortCircuitPython
and/or always evaluate both operands
Misconception
OutsideInFunctionNestingPython
Nested function calls are invoked outside in
Misconception
PreIncrementBeforeLoopJava
Pre-increment in update part of for loop means increment before loop body
Misconception
RecursiveFunctionNeedsIfElsePython
A recursive function needs to contain an if-else statement
Misconception
RecursiveMethodNeedsIfElseJava
A recursive method needs to contain an if-else statement
Misconception
RepeatDistributesScratch
Each block in a loop is repeated individually
Misconception
ResetStateEachLoopIterationScratch
The computation of all loop iterations starts from the state before the loop
Misconception
ReturnNoOutEdgeJava
In a control-flow graph, a return statement has no outgoing edge
Misconception
RightToLeftChainingPython
Chained accesses are invoked from right to left
Misconception
StatementMultipleOutEdgesJava
A non-condition node in a control-flow graph can have multiple outgoing edges
Misconception
TryCatchMandatoryJava
If code could throw an exception, you must surround that code with a try/catch block
Misconception
TryFinishesJava
Exceptions get thrown at the end of the try block
Misconception
ZeroInEdgesJava
A control-flow graph node (other than the entry node) can have zero incoming edges
Misconception
ZeroOutEdgesJava
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.