Avoid loop-the-loops in software

Charles Stover
3 min readJun 19, 2023

I recently reviewed a pull request for a software test suite, and I wanted to call out this particular code anti-pattern, which I refer to as a “loop-the-loop” on account of the reader’s need to jump back and forth between lines of the code module.

I share code snippets below to exemplify a loop-the-loop, the mental gymnastics required to comprehend a loop-the-loop, and how a refactor can improve the code’s readability.

--

--