Hexagonal architecture - Another way to the hexagone

Last updated May 10, 2022 Published Apr 13, 2022

I am not sure how this post is going to be, but the idea is to brain dump what is my current understanding of hexagonal architecture and try to make like a journal of that. As I improve my understanding I can improve this post and so on.

NOTE 1: Hexagonal architecture is usually mixed with the clean architecture, even though, it was used as an inspiration to the clean architecture, they are different. Valentina Cupác describes that on her talk in details.

NOTE 2: Found something that seems wrong and would like to contribute? Leave a comment and I can reply as fast as possible.

Hexagonal

I got to know hex architecture(I am going to follow this pattern from now on to refer to he hexagonal architecture) in the clean architecture book, indeed it was an inspiration to uncle bob in order to get the clean architecture in place.

Alistair Cockburn realized that there was a different approach of building applications instead of the classical layered architecture:

The attempted solution, repeated in many organizations, is to create a new layer in the architecture, with the promise that this time, really and truly, no business logic will be put into the new layer.

A more flexible way of dealing with different adapters in the application and using the same code to process business rule. Even though experts argue that there are the difference between open and closed layers, to avoid such interactions or constraints violations, in the hex architecture the approach is different stating that the goal is to avoid it by design instead of try to enforce a constraint.

Nevertheless, [1] says that hexagonal architecture is an example of a layered architecture as it conforms to all the constraints and properties of a layered architecture.

Another way to the hexagone

Definition

Hexagonal architecture is defined in different aspects. I named here the aspects I believe are key for such architectural style:

  • ports, as in the author description “The term “port and adapters” picks up the ‘’purposes’’ of the parts of the drawing. A port identifies a purposeful conversation”.
  • adapters, you might have many adapters for a single port.

On the book Strategic monoliths and microservices [2] Vaughn Vernon and Tomasz Jaskula also used a similar definition, on the other hand, what caught my attention to their definition is the way used to differentiate the layered architecture from hexagonal.

References

  1. [1]J. Stenber, “Exploring the Hexagonal Architecture,” 2014 [Online]. Available at: https://www.infoq.com/news/2014/10/exploring-hexagonal-architecture. [Accessed: 15-Apr-2022]
  2. [2]T. J. Vaughn Vernon, Strategic Monoliths and Microservices. The Addison-Wesley Signature Series, 2021.