12 Avoid optimizations and generality
This chapter covers
- Minimizing generality to reduce coupling
- Thinking of optimization in terms of invariants
- Managing the fragility from optimizations
Performance optimization and generality are two games programmers play that often hurt more than they help. When we say optimization in this chapter, we mean performance optimization, which involves increasing the throughput of code or reducing its duration. By generality, we mean the code encompasses more functionality, usually through more general parameters. To illustrate what we mean by generality and how it can be harmful, consider the following example.
If someone asks you for a knife, handing them a Swiss Army knife might be a godsend if the recipient ...
Get Five Lines of Code 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.