GoF Patterns: Where to Start?

While teaching C++ for novice software architects, I’m happy to see their willing to employ various OO design patterns to streamline and strengthen class-level architecture of academic projects they implement. Unsurprisingly, the first and foremost area of their interest is all around «Gang-of-Four» (GoF) patterns described as early as 1994 by Erich Gamma et al. in their world-known book.

Everyone who’s new to Gamma gets almost always confused about quantity and diversity of GoF patterns. Where to start? Besides recommendations kindly given by the book authors, it seems promising to take a look at projects made by, say, unseasoned practitioners. What’s used often and why?

As I can judge from my own experience and my students’ code base, top 5 GoF patterns could look as follows (well, three of five items go in pairs as long as they can handle slightly different OO design problems):

  1. State / Strategy: Allows to abstract and dynamically substitute different concrete algorithms to solve the same domain problem.
  2. Composite / Decorator: Provides a unified ADT interface for aggregates and leaf entities with or without some additional features.
  3. Bridge: Separates interface classes from implementation classes and makes them both interchangeable.
  4. Abstract factory / Builder: Encapsulates logic for creating complex problem-oriented entities.
  5. Observer: A good choice for model-view architectures.

Another group of remarkable GoF patterns in use among novice C++ architects are, alphabetically, Adapter, Facade, Mediator, and Proxy.

But to be honest, both groups of GoF patterns are  based upon non-GoF fundamental patterns such as Class Inheritance / Interface Implementation, Composition / Aggregation / Acquaintance, and Delegation.

Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:

Логотип WordPress.com

Для комментария используется ваша учётная запись WordPress.com. Выход /  Изменить )

Google photo

Для комментария используется ваша учётная запись Google. Выход /  Изменить )

Фотография Twitter

Для комментария используется ваша учётная запись Twitter. Выход /  Изменить )

Фотография Facebook

Для комментария используется ваша учётная запись Facebook. Выход /  Изменить )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.