Wednesday, June 26, 2019

Hexagonal Architecture for Beginners

The hexagonal architecture is one more approach to create maintainable software solutions (and it can be one more way to shoot yourself in the foot). The main idea is to separate core logic (business logic and domain) from frameworks. Usually, the first part is called inside and the last one is called outside. Inside provides a port to communicate with it, and at the same time, outside provides the implementation of this port called the adapter. This is why this particular development style has another name — the ports and adapters architecture.

Advantages

  • Ability to support multiple channels
  • Flexibility in choice of channels
  • Easy testing of core logic by the mock outside part

Implementation

Speaking of this implementation style in Java, it is easy to imagine that the classic interface plays a role in the port. Therefore, the adapter (the outside part) is the implementation of the current interface. This concept will be shown in the following simple Spring Boot application that will simulate the work of some stock (add/get some orders). The core of our app consists of business logic (OrderService) and the domain part (Order):



from DZone.com Feed https://ift.tt/2RyNOGM

No comments:

Post a Comment