- July 8, 2020
- Posted by: ASAT Consulting
- Category: Insights
Are changes inevitable? Plug & Play systems and components with Hexagonal Architecture
Monolith allows rapid development and expedited go live.
Product life cycle is dependent on its architecture. You cannot always ensure that you have the perfect architecture for your perfect product. During the conventional era, building a monolith was ideal.
Over time, applications evolve with customer feedback and business environments. They transform from a single board offering application to many specialized feature offerings. This is when monoliths are no longer ideal. They need to be replaced by special and specific services.
Monoliths become obsolete and decomposing due to various factors such as performance issues, maintainability issues, domain boundaries or because of any of the ilities of the application. I had covered more about illities of architecture in my earlier blog – Evolutionary Architectures.
If application design was developed with very tight coupling between components, then the process of decomposing and or modifying becomes an expensive affair. To protect products from entering into such a critical mode and allowing them to adapt for future changes with ease, it is ideal to embrace Hexagonal Architectures.
Sample Hexagonal Architecture
Basics of Hexagonal Architecture
Domain Objects: Objects where application domain logic and corresponding entities reside. Agnostic of persistence and external layers.
Data Layer: Contains repository interfaces and corresponding implementation to interact with underlying data stores. A layer with knowledge of reads and writes.
Resolvers: Proxies to accept requests from a client/input object and passing these to the real object as necessary. In simple terms, a resolver acts as an input handler. This can be triggered by any invoker such as Http request, Kafka consumer, scheduler, internal service … etc.
Adapters: Implementation (adapter) to interact with the underlying data store.
Consumers & Controllers: Layer for interacting with the system. Basically, an input into the application.
Advantages of Hexagonal Architectures
- Clean and pure domain: Application is not impacted by any technical and technology details.
- Agnostic of input and output implementations.
- Swappable/replaceable components/data stores without affecting underlying business logic.
- High-level of separation of concerns because of loosely coupled and agnostic layers.
- Increased testability: you can provide test replacements, test each layer of application and mock any dependencies.
Shield the core domain logic
Hexagonal Architecture is just one of many techniques for building applications where scope and responsibilities of an application will potentially evolve in future and current knowledge of such evolution is limited or non-existent. Your organization can shield the core domain logic from various external factors such as technologies, change in inputs, change in outputs etc, using this technique.