Chapter 6. DI refactorings

 

Menu

  • Mapping runtime value to ABSTRACTIONS
  • Working with short-lived DEPENDENCIES
  • Resolving cyclic DEPENDENCIES
  • Dealing with Constructor Over-injection
  • Monitoring coupling

You may have noticed that I have a fascination with sauce béarnaise, or sauce hollandaise in general. One reason is that it tastes so good; another is that it’s a bit tricky to make. In addition to the challenge of production, sauce hollandaise presents an entirely different problem: it must be served immediately (or so I thought).

This used to be less than ideal when I was having guests. Instead of being able to casually greet my guests and make them feel welcome and relaxed, I was frantically whipping the sauce in the kitchen, leaving them to entertain themselves.

After a couple of repeat performances, my very sociable wife decided to take matters into her own hands. We live just across the street from a restaurant, so one day she chatted up the cooks to find out whether there is a trick that would enable me to prepare a genuine sauce hollandaise well in advance. It turns out that there is, so now I can serve a delicious sauce for my guests without first subjecting them to an atmosphere of stress and frenzy.

Each craft has its own tricks of the trade. This is also true for software development in general and DI in particular. There are challenges that just keep on popping up, and in many cases there are well-known ways to deal with them.

6.1. Mapping runtime values to Abstractions

6.2. Working with short-lived Dependencies

6.3. Resolving cyclic Dependencies

6.4. Dealing with Constructor Over-injection

6.5. Monitoring coupling

6.6. Summary