Mahemoff.com

GoF Pattern Metaphors

The GoF Patterns can be presented using real-life examples. This is useful for educational purposes and might even evoke a geeky chuckle as well.
  • Background info below.

    A personal assistant is a Proxy and a pair of glasses is a Decorator. Use real-world metaphors to ramp up on your design pattern education.

    Creational Patterns

    Abstract Factory (87)

    Builder (97)

    Prototype (117)

    Singleton (127)

    Structural Patterns

    Adapter (139)

    Bridge (151)

    Composite (163)

    Note: Most recursive structures are examples of Composite.

    Decorator (175)

    Facade (185)

    Flyweight (195)

    Proxy (207)

    Behavioral Patterns

    Chain of Responsibility (223)

    Commmand (233)

    Interpreter (257)

    Iterator (257)

    Mediator (273)

    Memento (283)

    Observer (293)

    State (305)

    Strategy (315)

    Template Method (325)

    Visitor (331)

    Background - About the Pattern Metaphors

    The GoF Patterns are at once utterly powerful and absurdly simple. Yet, my experience indicates many pattern novices grasp neither their power nor their simplicity. A likely reason is lack of experience with object-oriented architectures. Many pattern learners are students who have not felt the pain of a complex system that has been mis-architected. Many others have sadly worked on systems so mis-architected that the confused tangle of code offered no afforances as to where patterns might prove useful.

    It's useful to complement software design patterns with stories from the real-world. Many of the GoF patterns do apply to real-world structures - structures of human organisations, work practices, buildings, towns, and so on. People learning patterns can relate to these things, so why not exploit the associations to improve learning? Amazing how even expert software developers are prone to discuss ideas in terms of real-life metaphors. In fact, some of the best architects I know frequently anthropomorphise their software when explaining how it works: "So this guy sends the message to him, but he's busy so he says 'send it later, or send it to one of my delegates now if you want'".

    Here, I present examples of real-world metaphors based on the GoF patterns. A good exercise for learners is to think of your own. In a learning context, the patterns can even be acted out. It might seem a bit funny, but activities like that are examples of elaborate learning, meaning you remember them.

    For ease of reference, the patterns are listed in the same order as the text. However, if you are learning the patterns, I recommend learning the patterns in this more effective order.

    Creative Commons License
    This work is licensed under a Creative Commons Attribution 3.0 Unported License.