Are design patterns a code smell? Are design patterns bad? That’s the rather bold claim made by Stuart Halloway in this post over at Relevance. At first blush, Stuart seems to have a pretty good case. As he points out, most if not all of the design patterns in the classic “Gang of Four” book are tightly tied to a particular family of programming languages, languages similar to Smalltalk, C++, and Java. Many of these patterns supposedly disapear or become trivially simple in more powerful programming languages like Lisp or Scheme (or I’m assuming, Ruby).
That may be true, but the conclusion drawn, that design patterns are a code smell, is just plain wrong. Design patterns, like any tool, can be misused. And the misuse of a tool is most definitely a code smell. Many of the design patterns in the GOF book probably are inappropriate for use in a functional language like Lisp or Scheme. However, I think an expert on either of those languages could easily write a book about design patterns in functional software design! Think of all the patterns that exist around when and how to use recursion, when and how to use macro’s, the use of higher order functions, etc.