O'Reilly logo

The Well-Grounded Java Developer: Vital techniques of Java 7 and polyglot programming by Benjamin J. Evans and Martijn Verburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Dependency Injection

This chapter covers

  • Inversion of Control (IoC) and Dependency Injection (DI)
  • Why DI is an important technique to master
  • How JSR-330 united DI for Java
  • Common JSR-330 annotations such as @Inject
  • Guice 3, the reference implementation (RI) for JSR-330

Dependency Injection (a form of Inversion of Control) is an important programming paradigm that has become part of mainstream Java development since about 2004. In short, DI is a technique in which your object gets its dependencies given to it, as opposed to having to construct them itself. There are many benefits to using DI—it makes your codebase loosely coupled, easier to test, and easier to read.

This chapter begins by cementing your knowledge of DI theory ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required