Let me pause for a bit to talk about what I’ve just done here. Firstly, I know readers will again be worrying about performance with this change, as many people are wary of repeating a loop. But most of the time, rerunning a loop like this has a negligible effect on performance. If you timed the code before and after this refactoring, you would probably not notice any significant change in speed—and that’s usually the case. Most programmers, even experienced ones, are poor judges of how code actually performs. Many of our intuitions are broken by clever compilers, modern caching techniques, and the like. The performance of software usually depends on just a few parts of the code, and changes anywhere e...
- Chapter 1 Refactoring: A First Example
- from Refactoring: Improving the Design of Existing Code
- Publisher: Addison-Wesley Professional
- Released: November 2018
Share this highlighthttp://www.safaribooksonline.com/a/refactoring-improving-the/20659334/