Hexagonal Architecture
Hexagonal Architecture
Presentation
The Hexagonal Architecture also known as “Ports and Adapters Pattern” has a very
tricky name, that’s because it does not refer to a particular layout or scaffolding that we
have to follow for our code. Its name came from a visual reminder for what a port is
indeed, since the first computers came with several ports to connect with other devices.
These ports had a shape like a Hexagon, if you use a little imagination and be
accomplice with the author.
But how do we implement this in Java and don’t die trying? First
we need to understand what is a port and then what is an
adapter.
Analogy
For example, a Video Card has many ports, but for now we need
to think it has a VGA port, so we bought a new monitor and it
came with only an HDMI port. Our Application is the whole
Computer and their video cards is one of his domains. The Video
Card Domain has ports to communicate with the outside
(Infrastructure), but we need an adapter to translate the analog
signal on a digital signal for the HDMI. Here comes the adapter
to allow us to connect the computer to monitor and enjoy our
games. So the video card sends the signal through a port to the
adapter, and receives the data to show on the screen. The
adapter is part of the infrastructure.
Diagrams
Explanation