Contents
- Introduction to Hexagonal Architecture
- Core Principles
- Components
- Steps
- Python Example
- Conclusion
Introduction to Hexagonal Architecture
Hexagonal architecture, aka “Ports and Adapters.”
- A strategic design pattern that emphasizes the “separation of applications”
- The central hub in the architecture is where the main core function resides.
- This core is surrounded by ports and adapters
- Ports: gates that leads to the outside world
- Adapters: keys to the gates where the outside data is translated into a language that the core can understand.
- “Talk inwards with simple structures; talk outwards through interfaces.”
Why do you use Hexagonal Architecture?
- It is a professional strategy to keep your system flexible and maintainable.
- Advantages
- Sepratation of Concerns
- Clear component rules
- Easy to understand the structure. Simplifying understanding for new developers
- Easy troubleshooting
- If you have business logic issue, examine domain model
- If you have event issues, examine the service model
- If you have interface issues, examine the port model
- etc..
- Simplified Testing
- Defined role and independent models make the testing easy and precise
When do you use and not use Hexgonal Architecture?
- Use
- Business logic focuses on the core domain
- Dependencies an point inward
- Don’t use
- If you’re business model is a basic CRUD
- Transformation and integration only
- Simple and Non existent domain