2. Plan
● TDD
o A test from Guice’s user's guide
(https://github.com/google/guice/wiki/Motivation)
o A DI implementation to pass the test
https://github.com/gdhuang/di_demo
3. Dependency injection
- A design pattern in which dependencies are injected
into a dependent object
Client.java
public Client(Service1 s1, Service2 s2)
Main.java
Service1 s1 = new Service1Imp();
Service2 s2= new Service2Imp();
Client c = new Client(s1, s2);
4. Guice
● Module - define bindings from types to implementations
● @Inject - specify a constructor is invoked by Guice
9. Conclusion
● Java
o Reflection http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/package-summary.html
o Generic http://www.drdobbs.com/java-generics-and-c-templates/184401818
● TDD
o Add necessary tests before implementing furthur than existing tests
o Practice with mockito http://stackoverflow.com/questions/7104485/how-does-jmock-and-
mockito-create-wrappers