Dependency Injection

Let us understand about Dependency Injection In Spring, Dependency injection(DI) is the design pattern which makes the application components to be loosely coupled by removing the dependency in the program code. Create Door.java which has dependency on SoundAlaram class as below package com.intro;   public class Door {     private SoundAlarm alarm;     […]

Share this article on

Need for Dependency Injection

Let us understand why do we need Dependency Injection As we all learned that DI is required since it provides loose coupling. Let’s see how this is needed in some scenarios by considering the below requirement Requirement : Client need to open the door, whenever it opens he wants the alarm to be activated,and whenever […]

Share this article on