Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. Dependency injection allows a client to remove all knowledge of a concrete implementation that it needs to use. Dependency Injection is a great way to reduce tight coupling between software components.
Let’s take an example of a dependency is when one of the objects depends on the concrete implementation of another object.
In this example, we have a class called Tea which uses another class or interface called Water in Tea class. Tea depends upon the class or interface Water. We can not use Tea without Water. When we create Tea we also need to create Water. This means Tea depends upon the class or interface Water.
There is three way to inject dependency in class:
I tried to describe Dependency Injection in a simple way. In my next article, I will try to explain the benefits of dependency injection and its relation to Dagger 2.
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.
Hussein Zawia
Co-founder, 24Dokan
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.