GOF Structure Diagram Considered Harmful

Posted October 1, 2000 by Joshua Kerievsky

There's a mistake that's repeated throughout the Design Patterns book, and unfortunately, the mistake is being repeated by new patterns authors who ape the GoF style. Each GoF pattern has a section called "Structure" that contains an OMT (or for more recent works, UML) diagram. This "Structure" section title is misleading because it suggests that there is only one Structure of a Pattern, while in fact there are many structures and ways to implement each Pattern. But inexperienced Patterns students and users don't know this. They read the Patterns literature too quickly, often thinking that they understand a Pattern merely by understanding its single "Structure" diagram. This is a shortcoming of the GoF Form, one which I believe is harmful to readers. What about all those important and subtle Implementation notes that are included with each GoF Pattern? Don't those notes make it clear that a Pattern can be implemented in many ways? Answer: No, because many folks never even read the Implementation notes. They much prefer the nice, neat Structure diagrams, because they usually only take up a third of a page, and you don't have to read and think a lot to understand them. Diagrams are seductive, especially to engineers. Diagrams communicate a great deal in a small amount of space. But in the case of the GoF Structure Diagrams, the picture doesn't say enough. It is far more important to convey to readers that a Pattern has numerous Structures, and can be implemented in numerous ways. I routinely ask folks to add the word "SAMPLE" to each GoF Structure diagram in the Design Patterns book. In the future, I'd much prefer to see sketches of numerous structures for each pattern, so readers can quickly understand that there isn't just one way to implement a Pattern. But if an author will take that step, I'd suggest going even further: lose the GoF style altogether and communicate via a pattern language, rich with diagrams, strong language, code and stories.