Michael Remijan
Michael Remijan

Reputation: 707

Java code example of Hexagonal Architecture?

I've been doing a lot of research on Hexagonal Architecture aka ports and adapters. I like the concepts, but struggling with some of the practicality. For example, the Domain isn't supposed to have the database access details (implementation). Instead that should be in the Framework layer. But there's a lot of "smarts" involved with data access in order to get the right data and it would seem to me that should belong in the Domain? So I'm looking for an example Java project that practically demonstrates the interactions between the Domain, Application, and Framework layers. Anyone know if something like this exists? I've not had much luck finding it. Lots of blogs about Hexagonal Architecture concepts, but nothing with concrete examples.

Upvotes: 3

Views: 2353

Answers (2)

chieuvh
chieuvh

Reputation: 41

This repository implements a small web app in the Hexagonal Architecture style using Spring Framework, as discussed in the book "Get Your Hands Dirty on Clean Architecture".

It also has a companion articles, you can read more here.

Upvotes: 0

Kacper
Kacper

Reputation: 451

I saw upvote on my comment, so I came with the idea that I will describe the best way to learn hexagonal architecture, in my opinion.

  1. Read what is DDD. Those two topics are practically the same. For this purpose I recommend the creator of this term Eric Evans and his book "Domain-Driven Design: Tackling Complexity in the Heart of Software".
  2. Read what is hexagonal architecture. There are good books. Uncle bob's: "Clean Architecture: A Craftsman's Guide to Software Structure and Design". Short description can be found here, on his website
  3. Watch some talks just in case. The one I found really helpful was Victor Rentea's presentation od Devoxx
  4. Analyse access modifiers in language you are developing. They are doing half the work.
  5. Work on it. Try to implement the way you understand it. Then you will see that those things works better those are missing and those are over engineering.
  6. Compare it with others code. It is really good feeling when you see that someone who has bigger experience implemented this the same way you did. This is the clue of this question. For this I recommend you this links.

Guy talk how important are access modifiers in hexagonal architecture. Example of code

Specific only implementation. Given in comment.

Upvotes: 3

Related Questions