In the Hexagonal pattern there are the following 3 concepts:
1. Ports: These are basically java interfaces that define the communication contract.
2. Adapters: They are the implementation of the Ports
3. Domain: This is the central part which contains all the business logic for processing data according to business rules. Ports are defined within domain, while adapters are defined outside domain.
Advantages of Pattern
Agnostic to the outside world
The first big benefit of Hexagonal Architecture is the fact that your application is now agnostic to the outside world. Typically a web application will be driven by HTTP requests through a browser. However, because the inner core does not know anything about the outer layers, the application can essentially be driven by any number of different controls.
Easier to test in isolation
Now that your application is agnostic to the outside world, it is much easier to test in isolation. This means instead of sending in HTTP requests, or making requests to a database, you can simply test each layer of your application, mocking any dependencies.
The Ports and Adapters are replaceable
The role of the Ports and Adapters is to convert requests and responses as they come and go from the outside world. This conversion process allows the application to receive requests and send responses to any number of outside technologies without having to know anything of the outside world.