A generalized solution, that solves not only one but many problems, is better than a specific one.
There are various ways to make a solution more generally applicable. In the simplest form this can be done by introducing a method with appropriate parameters. Other possibilities are classes, parametric types, callbacks, hook methods, etc.
A general solution abstracts from the specific tasks and solves a superset of them. Parameterization of some kind is used to specify what has to be done in a given situation.
Specific solutions tend to be fragile. When requirements change, a specific solution might not fulfill them anymore. In contrast to that a more general solution is more stable so there will be less need to change it.
Moreover a generalized solution can be reused in a variety of other situations. A specific solution can only be reused when exactly the same requirements appear again. So a general solution is much more reusable.
|Principles In "The Pragmatic Programmer"|
|Don't Repeat Yourself||Make It Easy To Reuse||Eliminate Effects Between Unrelated Things||Program Close To The Problem Domain||Keep Knowledge in Plain Text||Write Code That Writes Code|
|Crash Early||Use Assertions to Prevent the Impossible||Use Exceptions for Exceptional Problems||Finish What You Start||Minimize Coupling Between Modules||Configure, Don't Integrate|
|Put Abstractions In Code, Details In Metadata||Always Design for Concurrency||Separate Views From Models||Abstractions Live Longer than Details|