[)roi(]
Executive Member
- Joined
- Apr 15, 2005
- Messages
- 6,282
in opposition to "Self-documenting code"

Generic parameters can be a desirable quality in something like a reusable library or collection function where the input / outputs are known (e.g. map, reduce, ...), but using generics throughout an application codebase is certainly not going to help maintainability -- for that alone I'd call his advice an anti-pattern.
http://degoes.net/articles/insufficiently-polymorphic
:wtf:More precisely, if you can name your variables after more descriptive things than f, a, b, and so on, then your code is probably monomorphic.
Monomorphic code is much more likely to be incorrect than polymorphic code, because for every type signature, there are many more possible implementations.
Thus, descriptive variable names are a code smell, indicating your code is overly monomorphic and more likely to be broken.
Fortunately, you can turn this around with a little refactoring process I call, extract polymorphism from monomorphism. While this refactoring does not always eliminate monomorphism, it can defer it, which is an overriding theme of functional programming (defer all the things!).
...
Introducing polymorphism can constrain the space of possible implementations and make it simpler to mentally verify correctness of a piece of code. Completely polymorphic type signatures don’t permit descriptive variable names, but they do vastly constrain the space of implementations.
Generic parameters can be a desirable quality in something like a reusable library or collection function where the input / outputs are known (e.g. map, reduce, ...), but using generics throughout an application codebase is certainly not going to help maintainability -- for that alone I'd call his advice an anti-pattern.
http://degoes.net/articles/insufficiently-polymorphic
Last edited: