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 184.108.40.206 release ready!
Updated 12 August 2017
Dependency Injection is a process where by object define their dependencies that are, the other objects they work with, by the constructor argument, arguments to factory method or property that set on the object instance after it is constructed or returned by the factory class, this process is called DI (Dependency Injection).
Why we use Dependency Injection?
The main idea of DI is to decouple the tight coupling for the dependent objects from each other. so that it is usually testable and modifiable.
The problem occurring when in future we have changed some objects instance from an object then code modifiability is too difficult because of we will change all the instances of that object from the application. For Ex.-
there are two Type services that send messages from the application so if we use without DI such as –
In future, if we want to delete or change the TypeA message to another TypeC message then we manually change all the TypeA object from the Application, so it will the very hard process if complex application.
So, How can solve?
We create MessageService Interface that has send message property and all the Services implement MessageService Interface. and inject MessageService implementation class dependency from MessageApplication class via the setter method.
Your email address will not be published. Required fields are marked*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.