Dependency Injection Of Software Design Principle
Dependency Injection is design pattern in which one object supplies the dependencies of another object rather than calling itself. This design pattern follows “Dependency Inversion” of software design principle.
This Principle state that-
High Level modules should not depend on Low Level modules. Both should depend on abstractions.
Abstractions should not depend on details. Details should depend on abstraction.
First of all understand what is High level module and Low level module?
High level module means similar to classes which encapsulates complex operations and Low level module means it implements basic and primary operations. This both modules should not depend on each other but both should be depend on abstraction which remove dependency.
Let's understand by real-world example:-
Fan is object which performs various operations when it gets current or power after switch button is press. Here who is High level module Fan and Low level module is Switch Button. As per situation both module depend on each other but the main service is communicate between them is current or power and both module in this example depend on current or power service which act as an interface.
So from this example prove that “High Level modules should not depend on Low Level modules. Both should depend on abstractions”.
The main aim of this principle is to implement any (web, distributed , Dashboard, windows) application in loosely coupled pattern which given benefits like if we want do any changes in low level module which not affected on high level module.
To implement Dependency Inversion principle in application implement one technique which is “Dependency Injection” which achieving or inject dependency to a class by using three ways-
• SETTER PROPERTY
This blog by Visual Coder (Division of SQUAD Infotech Pvt. Ltd.)
About Visual Coder (Division of SQUAD) :-
Visual Coder(Division of SQUAD) is Mumbai s first dedicated Professional Training Center for Software Training and English communication. The strong foundation of Visual Coder(Division of SQUAD) is laid by Corporate Training Professionals, having mission to provide highly skilled and trained Software Professionals to IT companies.
Visual Coder (Division of SQUAD) is Professional Training Center, not an institute / class. Visual Coder(Division of SQUAD) conducts career oriented, Professional Training-cum-Placement programs (courses) .
About SQUAD:- We impart training JAVA/.Net /Software Testing/PHP/Digital Marketing and English Improvement program, imparting training to fresh graduates and offer them placements in various IT companies. We offer free placements, open to all candidates. All career aspirants who wish to pursue their career in IT, having possessed the technical skills, can approach us for their career path/growth and placement. – For Training and 100% placement call / whatsapp: 7718819172
SQUAD Specializes in:
• Training under Corporate trainers. • International Certification Preparation. • Get an exposure to REAL project testing. • Weekend sessions for working professionals.
• Audio/video lectures.• 100% Job Assistance / Guarantee until you get placed. • Technical & HR Interview Preparation. • Free Demo Lecture available prior to the commencement of new batch. • Group Discount Available. • Session for Personality Development and Communication Skill. • Free Reading material.
For More Contact Us:
·Nerul Office :
B - 117, 1stFloor, Nerul Railway Station Complex, Nerul (E), Navi Mumbai,
Maharashtra - 400 706
·Thane Office :
Shop No. 1 and 2ndFloor Terrace Office, Siddharth Tower, Thane(W),
Maharashtra -400 601