Examples of Hexagonal Architecture (Ports and Adapters)

3,577 views
Skip to first unread message

Miguel Casal Guillán

unread,
May 15, 2015, 4:48:16 AM5/15/15
to growing-object-o...@googlegroups.com

Hi people!

I'm reading the fantastic GOOS and I wonder if someone knows any example of Hexagonal Architecture in open source projects, mainly web oriented. So far I've only found little demos, more like proof of concepts. I'm looking for real projects that worth learning to better grasp the ideas behind this design pattern.


Many thanks.

Vincent Tencé

unread,
Jun 1, 2015, 12:40:34 PM6/1/15
to growing-object-o...@googlegroups.com
You can have a look at https://github.com/testinfected/simple-petstore

It's a web based application with a SQL backend, a few thousand lines of code. It features end-to-end tests, unit tests for the domain, views, controllers, and integration tests for the database

Cheers,
-- Vincent

Matteo Vaccari

unread,
Jun 1, 2015, 3:01:13 PM6/1/15
to growing-object-o...@googlegroups.com
Hi Miguel,

here is an exercise of mine, much smaller in size than Vincent's.  It was not meant to be a demo of Ports and Adapters, but hopefully it is a bit in that direction.  It's a restful server that plays a game of Hangman.  To build a JS client for it is left as an exercise.  (It's Java with no frameworks and with an embedded Jetty server.)


Here is another exercise written in Java for Android; it's an independent rewrite of Carlo Pescio's Ribbons exercise (http://www.aspectroid.com).  The point was to do as much TDD as possible in pure-Java.  So we needed to isolate ourselves very cleanly from the Android framework; in fact our middle-hexagon is in a separate module (think project).


Here is an unfinished web app that (if it was finished) would play the Italian card game of Scopa (Sweep).


Hope you find some of this useful!

Matteo




--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Miguel Casal Guillán

unread,
Jun 1, 2015, 5:57:35 PM6/1/15
to growing-object-o...@googlegroups.com

Thank you. It could be more or less what I'm looking for :)

Miguel Casal Guillán

unread,
Jun 1, 2015, 5:58:59 PM6/1/15
to growing-object-o...@googlegroups.com

Many thanks for your contributions. For sure they will be useful.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

Steve Smith

unread,
Jun 2, 2015, 5:27:34 PM6/2/15
to growing-object-o...@googlegroups.com
If you're using .NET, there is a detailed example in the DDD
Fundamentals course on Pluralsight (authored by Julie Lerman and me)
that you may find helpful. Unfortunately, it's not available unless
you are a subscriber.

Alternately, this is an older project that you may find useful (again
using .NET):
https://codecampserver.codeplex.com/SourceControl/latest#README.txt

Sidenote: Anybody interested in software craftsmanship, please back
and/or share this project to create a wall calendar of motivational
software principles:
http://bit.ly/KickSC2016

Cheers,
Steve
>>> email to growing-object-oriente...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Growing Object-Oriented Software" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to growing-object-oriente...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Steve Smith
http://Ardalis.com/
http://twitter.com/ardalis

Miguel Casal

unread,
Jun 3, 2015, 4:45:34 AM6/3/15
to growing-object-o...@googlegroups.com

Thank you!


El Tue, 2 Jun 2015 17:27:33 -0400
Steve Smith <ssmith...@gmail.com> escribió:

Jean Helou

unread,
Jun 3, 2015, 4:38:53 PM6/3/15
to growing-object-o...@googlegroups.com, Clément Bouillier, Florent Pellet, Emilien Pecoul
Hello Miguel, 

You may be interested by the mixter codebase : https://github.com/DevLyon/mixter

I hesitated to submit this code sample as it was intended to be an example of Hexagonal, however as one of my colleagues pointed out, it does end up implementing hexagonal. 

The mixter codebase is intended to be a koan based approach to help people gain a practical understanding of DDD/ES/CQRS. 
The exercise is designed to represent a simplified version of twitter. We cut through actual features but we demonstrate how to make different bounded contexts and aggregates interact (user authentication, session handling, message posting, user relations etc ) and since we wanted people to see it "work" so they could study an end to end application of the concepts, we built a partial REST api to manipulate the domain which students get as the last step of the exercise. This was done to show a full end to end working application.

The domain and business rules were built in full TDD and complete isolation from any technical concern, defining interfaces for things related to external world interaction or technical concerns. 
Then we created an actual web application using this domain which you can run and interact with.

It is not a production application and by and it is incomplete, some concerns are simplified but it does implements real-world use cases and does exhibit an hexagonal architecture. 

You will find the web application code in the solution branches. 
The repository currently contains 4 branches for the 4 languages this exercise was implemented in : c#, java, php and javascript. We are slowly working on an F# and scala version.


It will be simpler than Vincent's simple-petstore but maybe more complete than hangman.

I hope you will find it interesting
Regards,
Jean

Miguel Casal

unread,
Jun 3, 2015, 8:01:12 PM6/3/15
to growing-object-o...@googlegroups.com

Hey! The twitter exercise reminds me of a talk given by Gary Bernhardt
titled "Boundaries"

https://www.destroyallsoftware.com/talks/boundaries



El Wed, 03 Jun 2015 20:38:34 +0000
Jean Helou <jean....@gmail.com> escribió:

Reuven Yagel

unread,
Jun 7, 2015, 3:18:25 PM6/7/15
to growing-object-o...@googlegroups.com, florent...@gmail.com, epe...@gmail.com, clement....@gmail.com
Hello Jean,
I've cloned the mixter project and checked out the 1at stage, not sure where to start from (fixing compilation errors?)... Is there a more detailed guidance other then the slides?

Some other examples I cam across:
A simpler one from Steven Smith (not sure of it's status, maybe just a starter for the mentioned pluralsight course): https://github.com/ardalis/ddd-vet-sample
DDD Kata (but repository is quite in an initial stage): http://codingsolutions.blogspot.co.il/2011/10/short-ddd-kata.html

Thanks, Reuven

> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> > --
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Growing Object-Oriented Software" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to

> > more options, visit https://groups.google.com/d/optout.
>
>
>

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

Jean Helou

unread,
Jun 7, 2015, 5:40:08 PM6/7/15
to growing-object-o...@googlegroups.com, florent...@gmail.com, epe...@gmail.com, clement....@gmail.com
Hello reuven

the discussion was originally about hexagonal architecture examples and that can be found in the solution branches for each of the language. 

To follow the actual exercise, you are supposed to checkout the starting point for instance  java-workshop (or ${language}-workshop and replace ${language} by your language of choice)  

Once you have that checked out, you will get a first failing test. the initial failure is indeed a compilation error, exactly as if you were doing TDD writing down the symbols you want to use to express the test then implementing them.
By making you create the symbol, we expect you will be encouraged to think about why we placed this symbol there and this one here. Even using IDE helpers you will at least see the name of the class/method and have to think a little bit about the package structure reuqired to make the import works. 

Please note that there is a known bug in the starting point of the java project:  the @Test annotation is missing on domain/src/test/java/mixter/domain/core/message/MessageTest.java#whenAMessageIsDeletedByItsAuthorThenItShouldSendMessageDeletedEvent

have fun


> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> > --
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Growing Object-Oriented Software" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to

> > more options, visit https://groups.google.com/d/optout.
>
>
>

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

Steve Smith

unread,
Jun 19, 2015, 11:53:33 PM6/19/15
to growing-object-o...@googlegroups.com, florent...@gmail.com, epe...@gmail.com, clement....@gmail.com
That DDD sample ended up being just an initial spike. The full demo used for the Pluralsight course is much more feature rich. Unfortunately I can't share it since it is a subscriber-only part of Pliralsight's content (but you can download it with a trial subscription, I think).

Steve


> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> > --
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Growing Object-Oriented Software" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to

> > more options, visit https://groups.google.com/d/optout.
>
>
>

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Reply all
Reply to author
Forward
0 new messages