Writing Efficient Code
If the best approach is not to optimize, how can we avoid any need to improve code performance? The answer is to design for performance, planning to provide adequate quality of service from the outset, rather than trying to whittle it out at the last minute.
Some argue that this is a dangerous road to follow. Indeed, there are potential hazards for the unwary. If you try to optimize as you go along, then you’ll write at a lower level than needed; you’ll end up with nasty, hacky code full of low-level performance enhancements and back-door interfaces.
How do we reconcile these seemingly opposing views? It isn’t hard, because they’re not actually at odds. There are two complementary strategies:
Write efficient code.
Optimize code ...
Get Code Craft now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.