views:

240

answers:

2

Is the Bridge Pattern same as the Provider Pattern. I did not see the Provider Pattern listed in the GoF book

A: 

I would say they are "very similar," consider Steven Metsker's Design Patterns in C#: he provides an implementation of the Bridge pattern for Database Drivers on pg. 71. As I read it, it looks like the Provider Pattern in Bridge Clothing.

Lucas B
A: 

Not familiar with the Provider pattern. The purpose of the Bridge pattern is to de-couple abstractions from their corresponding implementations. Simplistic eg code:

class Abstraction
{
  IBridge _bridge;
  public Abstraction(IBridge implementation) { _bridge=implementation; }
  public DoStuff() { _bridge.DoStuff(); }
}

interface IBridge
{
  void DoStuff();
}

class BridgeA : IBridge
{
  void DoStuff() {...}
}

class BridgeB : IBridge
{
  void DoStuff() {...}
}
Garrett