How Does This Help Me Build Maintainable Software?
The Hexagonal Architecture style cleanly separates domain logic and outward-facing adapters. This helps us to define a clear testing strategy that covers the central domain logic with unit tests and the adapters with integration tests.
The input and output ports provide very visible mocking points in tests. For each port, we can decide to mock it or to use the real implementation. If the ports are each very small and focused, mocking them is a breeze instead of a chore. The fewer methods a port interface provides, the less confusion there is about which of the methods we have to mock in a test.
If it becomes too much of a burden to mock things away or if we don't know what kind of test we should use to cover a certain part of the code base, it's a warning sign. In this regard, our tests have the additional responsibility of acting as a canary – to warn us about flaws in the architecture and to steer us back on the path to...