2 ms·
> What if you have to introduce a modification to your logic that applies a transformation to the result? Should you modify it in 5 places, or 1? In 1 place, c
by SideburnsOfDoom 11y ago
> What if you have to introduce a modification to your logic that applies a transformation to the result? Should you modify it in 5 places, or 1?
In 1 place, clearly. The multiple-return version would require a bit more refactoring at this point, either extracting another method or introducing the "return value" state var at that point.
Why not code it with single return up front? Simple: most likely, You Aren't Going To Need It. The YAGNI principle says to make the code more complicated when you need to, not before.