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 is in a survival situation. However, imagine if the recipient is a chef in a professional kitchen; a paring knife might be more welcome. In this parable, as in code, the design accommodating the generality may be more burdensome than the generality is helpful. When it comes to generality, the context is everything.