Dependency inversion to the rescue
In this section, we will review a design approach known as the hexagonal architecture, based on the SOLID principles we already know. Using this approach allows us to use TDD more effectively across more of our code base.
We learned about the Dependency Inversion Principle previously in this book. We saw that it helps us isolate some code we wanted to test from the details of its collaborators. We noted that was useful for testing things that connected to external systems that were outside of our control. We saw how the single responsibility principle guided us into splitting up software into smaller, more focused tasks.
Applying these ideas to our earlier sales reporting example, we would arrive at an improved design, as shown in the following diagram:
Figure 9.2 – Applying SOLID to our sales report
The preceding diagram shows how we have applied SOLID principles to splitting up our sales report code. We...