From the course: Java EE: Design Patterns and Architecture
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
The Dependency Injection pattern
From the course: Java EE: Design Patterns and Architecture
The Dependency Injection pattern
- [Narrator] Dependency injection is one of the well-known and accepted design patterns that was not listed in the book Designs Patterns: Elements of Reusable Object-Oriented Software by the Gang of Four. Today it is being used widely in modern programming languages, both internally, and as best practices to promote loose coupling. The dependency injection pattern is based on the idea of inverting control. Instead of creating hard dependencies and creating new objects, either with a new keyword or look-ups, you inject the needed resources into the destination object. This approach has many benefits. The client does not need to be aware of the different implementations of the injected resources, making design changes much easier, unit testing using mock objects is much easier to implement, configuration can externalized, thereby reducing the impact of changes, and finally, a loosely coupled architecture allows pluckable structures. The basic idea behind dependency injection is to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.