2 ms·
"Design Patterns" are conceptual repetitions in code. In a sense, a "design pattern" represents that which the programmer has failed to abstract away in a libra
by Peaker 16y ago
"Design Patterns" are conceptual repetitions in code. In a sense, a "design pattern" represents that which the programmer has failed to abstract away in a library using his programming language.
It may be a failure of the programmer, or a failure of the language.
Established "Design Patterns" are hard or impossible to abstract away in a library, or they would not have become standard "Design Patterns".
Instead of looking at conceptual repetitions (of nice design concepts) as a good thing, we should look at them as a workaround for the languages' inability to abstract away these things in a library.
Many design patterns in C++ or Java are just simple closures or dynamically-typed results in Python:
* The Visitor pattern is the combination of multiple-dispatch and inversion of control pattern. Multiple dispatch is possible to generalize in a library for all cases or is a language feature in various languages.
* The inversion of control pattern is just a higher-order function in a language that supports these properly.
* The singleton pattern is just a lazily-initialized global variable, and can be abstracted by a library in some languages.
Design Patterns are in this sense, "language smell". It is a good measure of what kinds of useful things are hard or impossible to implement as libraries.