Developer
Developer

Reputation: 18679

Is Bridge Pattern same as the Provider Pattern?

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

Upvotes: 2

Views: 960

Answers (3)

John Nicholas
John Nicholas

Reputation: 4836

Maybe a difference is that a provider pattern would potentially encapsulate many bridges?

I am also asking myself the same question and finding it hard to see the difference.

I see provider pattern as basically being the strategy pattern.

A question that may help and clear up my confusion

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

IE yes they look similar in examples but their purpose is different.

Upvotes: 1

Garrett
Garrett

Reputation: 1790

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() {...}
}

Upvotes: 0

Lucas B
Lucas B

Reputation: 12013

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.

Upvotes: 0

Related Questions