Dependency Injection

  • Martin Kirst
  • Nirdosh

SOLID

 

 

SOLID

SRP: Single Responsibility 

A class should have a single responsiblity

OCP: Open-Closed

Software entities should be open for extension but closed for modification

LSP: Liskov Substitution

objects in a program should be replaceable with instances of their subtype without altering correctness of the program.

 

ISP: Interface segregation

Many client-specific interfaces are better than one general-purpose interface

DIP: Dependency Inversion

one should depend upon Abstractions.

IOC: Inversion Of Control

  #ruby
  puts 'What is your name?'
  name = gets
  process_name(name)
  puts 'What is your quest?'
  quest = gets
  process_quest(quest)
require 'tk'
  root = TkRoot.new()
  name_label = TkLabel.new() {text "What is Your Name?"}
  name_label.pack
  name = TkEntry.new(root).pack
  name.bind("FocusOut") {process_name(name)}
  quest_label = TkLabel.new() {text "What is Your Quest?"}
  quest_label.pack
  quest = TkEntry.new(root).pack
  quest.bind("FocusOut") {process_quest(quest)}
  Tk.mainloop()

Popular IOC-Containers

  • Spring
  • Google Guice 
  • Java EE6 CDI
  • PicoContainer
  • Dagger

Dependency Injection

  • ​​Software Design Pattern
  • Implements IOC
  • A dependency is an Object ( service)
  • Assembler

Spring IOC Container

Hands On ...

Dependency Injection

By Nikunj Parmar

Dependency Injection

  • 711