Search code examples
design-patternsdependency-injectioninversion-of-controlioc-containerbridge

Differences between 'Bridge Design Patterns' and 'Inversion of Control with an IOC container'


About Design Patterns, my perception about 'Inversion of Control with Dependency Injection ' and 'Bridge Design Pattern' is that they do the same thing, but Dependency Injection can and usually uses an IOC container.

Which are the differences between 'Inversion of Control with Dependency Injection ' and 'Bridge Design Pattern'?


Solution

  • A lot has been written here on stackoverflow about Dependency Injection (just visit the Dependency-Injection Tag info page for good references), so it's not useful to repeat that here.

    The Bridge Pattern is a pattern, which means that you can use it to design a certain part of your application, just as you can use an abstract factory, decorator, adapter, facade, you name it. Inversion of Control on the other hand can be seem as an overall theme that you can use to make the complete application more loosely coupled. So it's not that you should use one over the other.

    If you even look at the Wikipedia article about the Bridge Pattern you see that the java example of the bridge pattern uses (constructor) dependency injection to inject the DrawingAPI abstraction into the Shape and CircleShape types.