July 2001
Beginner to intermediate
368 pages
6h 52m
English
In learning the Bridge pattern, I looked at a problem where there were two variations in the problem domain—shapes and drawing programs. In the problem domain, each of these varied. The challenge came in trying to implement a solution based on all of the special cases that existed. The initial solution, which naively used inheritance too much, resulted in a redundant design that had tight coupling and low cohesion, and was thus difficult to maintain.
You learned the Bridge pattern by following the basic strategies for dealing with variation:
Find what varies and encapsulate it.
Favor composition over inheritance.
Finding what varies is always a good step in learning about the problem domain. In the drawing program example, I had one set ...