Knowledge
Search knowledge... ⌘K
Knowledge · Anti-Patterns
Smell Loops
Code smell indicating imperative loops that could be replaced with pipeline operations
Tags
refactoring-fowlercode-qualitymaintainabilitycode-smell2nd
Impact
Loops have been a core programming construct since the earliest languages but are showing their age. First-class functions are now widely supported, and we can use pipeline operations like filter, map, and reduce to better express what we want. Pipeline operations help us quickly see the elements that are included in the processing and what is done with them, whereas loops often bury this information.
Symptoms
- Loops have been a core programming construct since the earliest languages but are showing their age. First-class functions are now widely supported, and we can use pipeline operations like filter, map, and reduce to better express what we want. Pipeline operations help us quickly see the elements that are included in the processing and what is done with them, whereas loops often bury this information.
Source
Martin Fowler — Refactoring: Improving the Design of Existing Code, 2nd