BridgeVersusStrategyPatternComparison

From Pattern Repository Wiki
Jump to: navigation, search

Encapsulation

Strategy 1.jpg
The Strategy Pattern encapsulates a single varying algorithm. The consumer of the algorithm does not couple to any particular implementation of the Strategy type, nor to the fact that the type is abstract, nor to the fact that there is a variation in place.

Bridge 1.jpg
The Bridge Pattern encapsulates three variations; the variation of the entity object ("abstraction" in GoF parlance), the variation in the behavior object ("implementation" per GoF), and the different way each entity uses the behavioral abstract type.

Risk

Because the two "sides" of the Bridge Pattern are related, this carries the risk that a new implementation of the entity variation may require the interface of the behavioral variation to change, usually by getting larger. This may also require existing implementations of the behavioral variation to change, as they will have to support the new method in the interface they implement.


The Strategy Pattern carries no such risk.