Design Patterns In Dynamic Programming

"Design Patterns in Dynamic Programming" by PeterNorvig is available at,

wherein he found that 16 of the 23 patterns in Design Patterns were "invisible or simpler" in Lisp (for example, because of the power of higher order functions).

Part of what is interesting about this is that it seems to contradict to some extent the traditional insistence that design patterns are not about language features.

Some of the DesignPatterns are "workarounds" for the low-level nature of C++. One common use of the WrapperPattern, for instance, is the PimplIdiom - allowing the implementation details of an object to be truly private, rather than features declared "private" but in a public header file.

In addition, the various flavors of WrapperPattern are greatly simplified if your language supports has things like delegation, MetaObjectProtocols, or other reflective capabilities. In C++, one must manually write forwarding functions for everything, which is a RPITA.

Also, the BuilderPattern is a work-around for a C++ limitation. The obvious way to achieve what the BuilderPattern achieves is to have a base-class constructor which calls a bunch of virtual methods, which can be be overridden by the sub-classes (or provided for the first time, if they were abstract on the base class). This doesn't work in C++ since function calls made within the construction phase of the base class are not polymorphic. (There may be occasions when you would still need to use builder classes without this limitation, and there seem to be versions of the BuilderPattern which are more complicated, but I think I have the essence of it here). The BuilderPattern is just about polymorphic construction, which is hampered if your constructors don't support polymorphism!

"it seems to contradict to some extent the traditional insistence that design patterns are not about language features"

Design patterns are not about language features, but language features are about design patterns. A programming language implements design patterns that were found to be useful in earlier languages.

No. Your restatement is precisely what is widely denied. When someone says "my new programming language has built-in support for all of the standard design patterns!", the response they get is "no, it doesn't, that's not how it works; a design pattern is a pattern discovered in code, not about the particular code that implements that pattern."

Exactly, which is why it becomes a language feature, and is no longer called a design pattern in that language. Patterns are discovered in code, but eventually, they work their way into languages, if they are found useful enough.

Funny, that one of the oldest languages on the block incorporates many patterns discovered in code since created after lisp was invented. Shame, that progress is not measured in forward strides.

See also: AreDesignPatternsMissingLanguageFeatures

View edit of November 9, 2006 or FindPage with title or text search