Spokes.wiki Search About
Defined Term practice updated Wed Aug 05 2026 00:00:00 GMT+0000 (Coordinated Universal Time)

Design patterns

Named, repeatable solutions to recurring program-structure problems, formalized for object-oriented code by the Gang of Four in three groups: creational (abstracting instantiation), structural (composing objects into larger ones) and behavioral (responsibility and communication between objects).

The claim this spoke cares about is not what the patterns are but what they are made of. rethinking-java-design-patterns rewrites five of them in modern Java and the scaffolding disappears each time: a Factory becomes a constructor reference held on an enum constant, a Visitor becomes exhaustive pattern matching over a sealed type — where the compiler proves the switch is total, so double dispatch, the accept method and the default branch all go away.

Patterns as a workaround for missing features

Read that way, a design pattern is a language deficiency written down and given a name. The Visitor exists because a language cannot dispatch on the shape of data; give it sealed types and pattern matching and the pattern is a switch. The Factory exists because construction cannot be abstracted; give it functions as values and the pattern is a function.

Which makes the GoF catalog partly a portrait of C++ and early Java, and predicts that a language with different primitives needs different patterns rather than fewer. clojure never needed the Factory — functions were always values — and its macro system means anything repeated enough can be absorbed into the language rather than described in a book. c has no objects, so the catalog largely does not apply, yet the same problems reappear as function pointers and tagged unions with no names to call them by.

The tension worth keeping. If patterns dissolve into features, a language’s expressiveness is measurable by how few patterns it needs — an attractive claim with nothing behind it. The counter-reading is that patterns are vocabulary, and naming a recurring shape has value even when the language implements it in one line. Nothing in this corpus settles it, and both readings appear in the same article.

rethinking-java-design-patterns · programming-language · clojure · c · synthesis