4 DI patterns
In this chapter
- Composing object graphs with Composition Root
- Statically declaring required Dependencies with Constructor Injection
- Passing Dependencies outside the Composition Root with Method Injection
- Declaring optional Dependencies with Property Injection
- Understanding which pattern to use
Like all professionals, cooks have their own jargon that enables them to communicate about complex food preparation in a language that often sounds esoteric to the rest of us. It doesn’t help that most of the terms they use are based on the French language (unless you already speak French, that is). Sauces are a great example of the way cooks use their professional terminology. In chapter 1, we briefly discussed sauce béarnaise but we didn’t elaborate on the taxonomy that surrounds it.
A sauce béarnaise is really a sauce hollandaise where the lemon juice is replaced by a reduction of vinegar, shallots, chervil, and tarragon. Other sauces are based on sauce hollandaise, including Mark’s favorite, sauce mousseline which is made by folding whipped cream into the hollandaise.
Did you notice the jargon? Instead of saying, “carefully mix the whipped cream into the sauce, taking care not to collapse it,” we used the term folding. Instead of saying, “thickening and intensifying the flavor of vinegar,” we used the term reduction. Jargon allows you to communicate concisely and effectively.