DEV Community

Hexagonal Architecture in Java

Anshul Bansal on December 15, 2019

1. Overview In this quick article, we'll discuss Hexagonal Architecture in Java through a practical example. 2. What is Hexagonal Architecture? ...
Collapse
 
jingxue profile image
Jing Xue

There seems to be a gap between EmployeeService and EmployeeDBPort. Presumably EmployeeService would invoke EmployeeDBPort to communicate with the database?

Collapse
 
smartyansh profile image
Anshul Bansal • Edited

In this case EmployeeService is actually EmployeeServiceAdapter that communicates with the database.
I've named the EmployeeService as the EmployeeServiceAdapter, to let reader know that it act as an Adapter.
Thanks for pointing it out. I'll mention in the article.

Collapse
 
jingxue profile image
Jing Xue

Well, now this call chain looks just like a classic three-layer architecture. In particular the call from the controller to the DBPort (actually an implementation of the DBPort) feels somewhat "inside out". If you look at the stereotypical HA diagram, it gives the impression that all ports are external facing.

Perhaps a follow-up expanding on the differences between HA and the classical layered architecture?

Thread Thread
 
smartyansh profile image
Anshul Bansal

Yes, it looks like a classic three-layer architecture. However, the pattern doesn't talk about the layers. Rather, it talks about ports and adapters.
HA expose interface to consume the inside component through a port and adapter is the middleware software component to interact with a port. Adapter can be in multiple technologies.

Thanks for suggesting a follow up on the comparison between HA and classical layered architecture.

Collapse
 
smartyansh profile image
Anshul Bansal

Good point. We can do that too.