Control Flow
Pronunciationkun-TROHL FLOH
Definition
Control flow is the order in which a program's statements run, decided by conditions, loops and function calls.
Where you hear it
In beginner programming courses, code reviews that simplify nested conditions, and debugging sessions that trace what ran.
Examples
The control flow is hard to follow because of so many nested conditions.
An early return simplifies the control flow.
A break inside the loop changes the control flow, so the code after the loop runs next.
Common mistake
Nesting conditions several levels deep. Return early or split the code into small functions to keep the flow flat.
Don't confuse with
Data flow, which is how values move between functions, not the order in which code runs.
Say it at work
- In a meeting or chat
Let's flatten the control flow with guard clauses.
- In an email or ticket
Walk me through the control flow when the request fails.
Keep exploring
More in Programming Fundamentals