Chapter 11. Dependency injection in action!
This chapter covers:
- Building a complete web application from scratch
- Seeing DI principles in a working application
- Applying useful design patterns
- Solving many common problems
“A computer lets you make more mistakes faster than any invention in human history—with the possible exceptions of handguns and tequila.”
Mitch Radcliffe
In this chapter we’ll put all of the things you’ve learned so far in this book into practice in a real, working application. While there probably aren’t enough pages to demonstrate a large enterprise application, we’ll look at a succinct application that gives us all the salient features of a broader program.
This program will start from bootstrapping the injector in a web application and walk through designing services for persistence, transactions, and user interactivity. We’ll also show how to apply some useful design patterns (such as the Provider pattern from chapter 5) and ways to properly leverage scope, lifecycle, and interception (AOP).
Let’s start by defining what this program will be.
I’ve chosen to do a simple, trivial clone of the popular microblogging service Twitter. (This isn’t in the least bit because I spend large chunks of my day on Twitter!) While I was writing this chapter, I thought crosstalk was cool code name.