Member-only story
What is the biggest mistake people do when working on the hexagonal architecture ?
Not applying properly the dependency inversion
That is the 5th principle (D) from SOLID principles. The idea is to invert the dependency in the outside-in direction, else it would be in the same direction (left to right) as for the interaction (or uses), which is the flow of calls.
🤷♂️ Consequence
The domain is not well isolated. Then we loose the benefit of using this architecture style. That is to emphasize on the domain isolation, which allow more clarity on the domain model.
❓ How to invert the dependencies
1️⃣ Define the port using interface making abstraction (in java, typescript, …)
2️⃣ Implement adapter by implementing the interface
3️⃣ Inject the adapter to the domain service (or usecase function)
4️⃣ Expose that usecase on the left hand side (driver endpoint)