Are the GOF Gamma patterns suitable?

Are the GOF Gamma patterns suitable?

Postby Cuchulainn » Mon Jun 10, 2013 5:17 pm

One of the topics that the GOF book does not describe is which Abstract Data Types (ADTs) to use in a particular content. This is especially evident with behavioural design patterns (for example, Observer and Mediator to name two) in which ah-hoc data structures are used to model object dependency graphs. The Observer (and MVC) pattern, for example, employs sequential containers (usually lists, set or vectors) to define dependencies between subjects and observers that allow us to model simple tree structures of depth (we not that an observer cannot simultaneously be a subject; to have this functionality we can use the Propagator pattern). It is possible to reduce complexity in the Observer we can employ a Change Manager as described in GOF 1995, page 299. This is an implicit realisation that the data structures are not flexible, especially when we wish to model complex many-to-many relationships, multiple interdependent subjects and when we wish to reduce coupling. A related problem is how GOF uses subtype polymorphism to effect the change propagation mechanism; each observer must implement a member function conforming to a given (rigid) signature. This also restricts the applicability of the pattern to more complex and interesting applications. Developers usually employ workarounds (for example, multiple inheritance in C++) but the resulting code becomes a maintenance nightmare in general.

Based on the above observations, we design behavioural patterns using a hybrid object-oriented/functional model. We also design these patterns using a two-layered approach:

. Layer 0: This is the lowest (data) level and it is here that we design and employ the data structures that are appropriate to the problem at hand. In the most general case, we note that directed graphs are able to support the basic and extended requirements of the Observer pattern. Any object can be a subject for several events and an observer for several events.

. Layer 1: The code at this level implements code that operates on the data structures in layer. Instead of using subtype polymorphism we use functional programming features as seen in .NET delegates, C++ 11 function wrappers and bind and the Boost signals2 library?
User avatar
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Return to Design Patterns

Who is online

Users browsing this forum: No registered users and 1 guest