When do you use the Bridge Pattern? How is it different from Adapter pattern?

Charles Graham picture Charles Graham · Nov 26, 2008 · Viewed 84.6k times · Source

Has anyone ever used the Bridge Pattern in a real world application? If so, how did you use it? Is it me, or is it just the Adaptor Pattern with a little dependency injection thrown into the mix? Does it really deserve its own pattern?

Answer

Anton Shchastnyi picture Anton Shchastnyi · May 21, 2012

There's a combination of Federico's and John's answers.

When:

                   ----Shape---
                  /            \
         Rectangle              Circle
        /         \            /      \
BlueRectangle  RedRectangle BlueCircle RedCircle

Refactor to:

          ----Shape---                        Color
         /            \                       /   \
Rectangle(Color)   Circle(Color)           Blue   Red