
“Sir, we’re in a ‘Do-Loop’.”
I’ve been in meeting after meeting where some non-programmer will say, “It appears we’re in a Do-Loop.” The intention is to indicate that they’re in a situation they can’t get out of, or a “do loop” with no exit plan.
A Do-Loop executes a block of code until it finds an exit. If there’s no exit, it runs indefinitely and can crash your program.
A Do-Loop (by itself) is the same thing as doing something for an infinite amount of time. In other words, a Do-Loop without a condition runs forever.
The issue I have with this saying is that a “do loop”, by definition, cannot be entered into without an exit, or a condition to evaluate. Saying you’re in a do-loop suggests you don’t have an exit plan.
An example of a real-life “Do Loop” is an employee on a performance improvement plan. The employee improves, meets the plan, and then starts slipping again. So they’re put back on the plan, and the cycle repeats. You’re now in a loop you can’t get out of easily because there’s no foreseeable exit.
“Help us, we’re in a ‘Do-While’ Loop!”
A Do-While Loop executes a block of code while something is true.
A better thing to say is, “We’re in a Do-While Loop.” At least the loop evaluates a condition to exit instead of running forever.
An example of a real-life “Do-While” loop is a cashier checking out your groceries. The cashier will scan your groceries “while” you still have items.
“You’re in a ‘Do-Until’ Loop, aren’t you?”
A Do-Until Loop executes a block of code until something is false.
A “Do-Until” loop is doing something until someone tells you to stop. For example, the sprinklers will be on to water the lawn until fall.
“My ‘While-Loop’ catches all the things.”
Another phrase might be, “We’re in a While-Loop, sir.” A While-Loop evaluates a condition before executing a task within the loop. If the condition is never met, the loop will run forever, just like a do-loop.
A While-Loop checks if something is true, then evaluates the code if it is.
An example of a “While-Loop” is checking whether an employee will pass a drug test before and during employment.
Conclusion – Don’t be in a “Do-Loop”
If you’re in a do-loop, you’re in a loop with no exit. How you got there is a mystery.
So next time someone says, “We’re in a Do-Loop”, sigh, mutter some expletives to yourself, and hope they meant a “Do-Until” or “Do-While” loop.








Leave a Reply