What is Dependency Injection & Polymorphism
" Dependency injection is the way to decouple conventional dependency relationships between objects. " What is meant by Dependency ? Suppose there are two classes A and B. A can not carry out works without B and A can not be reused without re using B. For this kind of scenario we said " A depends on B " A – Dependant B – Dependency What Is meant by Decouple ? A and B classes are decoupled if A can be use without B and and B can be used without A. Lets assume creating a drawing application with Square , Triangle and Application classes. Square and Triangle class has same method name called draw() which draws square for a Square object and triangle for Triangle object. Polymorphism to rescue ! The Greek meaning of the word "polymorphism" is "having different forms". Same object having different object behaviors ! Added interface called Shape and the common method draw() for both ...