Enhancing Testability and Maintainability Through SOLID Principle
Apply the principle of dependency inversion within hexagonal architecture to unlock unparalleled testability and code organization by dividing the application into external systems, adapters, ports, and the domain model.
In this lesson, we’ll 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.
Implementing SOLID principles
We learned that the Dependency Inversion Principle helps us isolate some code we want 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 illustration:
Get hands-on with 1400+ tech skills courses.