Member-only story

What is the biggest mistake people do when working on the hexagonal architecture ?

Kong To
2 min readMar 2, 2025

--

Not applying properly the dependency inversion

Direction of dependencies vs flow of calls

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)

💪 Example

Driver calling search usecase function in the provider which injects the adapter implementing the port

--

--

Kong To
Kong To

Written by Kong To

Architect, Engineer, Developer, Code, Code Crafter... whatever but code quality matters

No responses yet