I was questioned by a colleague about the design pattern of my implementation of a WCF windows service in a ASP.net client application and I really could not tell whether it is Bridge or Adapter!
Here is the implementation:
I was always thinking of it as an implementation of Adapter pattern, but really I can not tell why isn't it Bridge!
I have read all the posts here in SO, GoF and wikipedia but it really makes no sense!
From my understanding, Both patterns point at an existing type, both decouple an abstraction from its implementation am I missing a point?
Here's from GoF:
The key difference between these patterns lies in their intents. Adapter focuses on resolving incompatibilities between two existing interfaces. It doesn't focus on how those interfaces are implemented, nor does it consider how they might evolve independently. It's a way of making two independently designed classes work together without reimplementing one or the other. Bridge, on the other hand, bridges an abstraction and its (potentially numerous) implementations. It provides a stable interface to clients even as it lets you vary the classes that implement it. It also accommodates new implementations as the system evolves.
I don't fully understand the above statement,
Update:
Again from GoF:
Remember that an adapter makes two existing interfaces work together as opposed to defining an entirely new one.
Does it mean that changing the existing interface so that it can work with another interface is an implementation of Adapter?
Update2:
Just found this incredible article: Illustrated GOF Design Patterns in C#
This is true Bridge Patter structure:
I was missing the fact that the Bridge pattern lets you combine the different abstractions and implementations and extend them independently
I think you don't have pure GoF pattern here. It's something between Decorator and Adapter. You are changing interface of service client (adapting it to your needs). But also you are adding new responsibilities to client (logging and error handling) - thats a decorating part. If you would stay with original service interface, it would be pure Decorator.
UPDATE: Any usage of inheritance does not mean, that we are using some GoF pattern. There are several things your current architecture missing to be Bridge:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With