Dependency Injection Explained

  1. Configuration file
  2. Decorator
  3. Manual registration in code
  1. Constructor
  2. Setter
  3. Interface
public class WebAgency implements Employer{  public WebAgency(FrontendDeveloper frontend){
this.frontend = frontend;
}
}
public class FrontendDeveloper implements ICanDoHTML, ICanDoCSS, ICanDoJS{
...
}
public class AngularFrontendDeveloper extends FrontendDeveloper{
...
}
WebAgency bestWebAgency = new WebAgency(...)
public class WebAgency implements Employer{
...
public void setWebDesigner(WebDesigner designer){
this.webdesigner = designer;
}
...
}
public interface Employer {
public void setUXDesigner(UXDesigner designer);
}
public class WebAgency implements Employer{
...
public void setUXDesigner(UXDesigner designer){
this.uxDesigner = designer;
}
...
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dennis

Dennis

I am a full stack developer working mainly on java/kotlin and angular/react techstack. I hope my writings can help others pick up the technical knowledge easily