Gyh's Braindump

Dependency Injection

source
Guice Motivation

Dependency Injection is a Design Pattern

Advantages

  1. Easy to write tests
    • e.g.: classes with database instances
  2. Dependency is exposed by API signature, not hidden in the code
    • after adding a new dependency
      • no need to manually check the tests to find out which ones will fail
      • no need to worry about forgot initializing the new dependency in the code

Links to this note