imperative / Java
Representation
Collected by Matthias Hauswirth — Compilers (control-flow graphs) and flow charts
Understand concept of selection from structured programming (conditional statements like if, if-else), and make clear that a statement may or may not execute, based on a decision taken earlier in the control flow.
PL | NM |
---|---|
... | ... |
if condition | diamond-shaped node |
condition outcome | label on an arrow coming out of a condition (e.g., true, false) |
The idea of a 'selection' in structured programming, where a data (the condition's value) is turned into control flow (the next statement to execute).
When introducing if-statements
Requires prior introduction of 'Sequence'. Mismatch for short-circuit operators (&&, ||) or conditional expressions (c ? a : b), which don't map as naturally.
This is the second in a sequence of "Control Flow as Graph" notional machines:
The following video Matthias Hauswirth uses the "Control Flow as Graph"
notional machine in his "Programming Fundamentals 2" Bachelor course
to explain if
-statements in Java:
This notional machine is implemented by the Informa Clicker tool. This tool allows students in a classroom to construct control flow graphs in in-class clicker exercises.
Do you have feedback on this notional machine? Did you find a mistake, or do you have a request for improvement? You can create an Issue on GitHub, where the description is hosted. This way we can see your feedback and address it.
For this, you need a GitHub account. Then follow this link to see the source file of this page. In there, click the ... left of the highlighted line, then pick "Reference in a new issue".