Question

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'?

Was it helpful?

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.

OTHER TIPS

there is a primary difference between them, that is the base concept of them. Bridge pattern uses DI for implementing. in bridge pattern we inject the class that inherited from interface that our abstract class need it. u can see bridge pattern desc in here: https://www.geeksforgeeks.org/bridge-design-pattern/ and as been told DI in here: https://stackoverflow.com/tags/dependency-injection/info

i hope it helps...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top