Refactoring a layered architecture application into a hexagonal one
By now, we have an idea of how to implement a layered architecture application. Let’s refactor this application we have just developed into a hexagonal one. This exercise will highlight the significant differences between the two architectures.
Implementing the Domain hexagon
The Domain hexagon contains data and behaviors with core system logic. In the following steps, we’ll see how to refactor some data and behaviors from the layered application using the hexagonal approach:
- While using the layered architecture, we started developing the system by implementing the data layer. We’ll refactor it into a Domain hexagon containing only a
User
domain entity class:@Getter @Setter @RequiredArgsConstructor @NoArgsConstructor public class User { private Long id; @NonNull private String email; @NonNull...