Skip to content
Thomas PIERRAIN edited this page May 10, 2016 · 29 revisions

Day 20 (May 9th 2016)

A Logbook entry written by @tpierrain

My refactoring journey towards Hexagonal Architecture

After few debates on twitter and a blog post to clarify why Hexagonal Architecture != Layers in my opinion, I decided to show an example of code to the community in order to continue the discussion. Since I'm not allowed to push some code outside my company, I started to reawaken the #SORLunchBox pet project to make it hexagonal.

I took me few days (of delay) since I could only work on it during the transports (metro, train,...) and few early mornings. The most important task was to move out our Market naive implementation into another project (with a new name: ApiMarketGateway).

To help you to grasp what the Smart Routing System (SOR) is and how its Hexagonal Architecture articulates for it, I also draw some sketches.

And before someone is telling me: xkcd

I'd like to add few...

Disclaimers:

  • The #SORlunchbox project is quite young and immature implementation (it's just a beginning). As of today:

  • It support 1 financial instrument only (implicit within the code ;-(

  • Even if it's event driven, the code is mainly synchronous ;-(next step will be to make it reactive and thus asynchronous)

  • There are many missing opportunities to use proper 'DDD' Value types (i.e. to replace all the decimal prices (primitive obsession) with an Amount Value type embedding the currency for instance)

  • ...

  • Watch only the CSharp code since the FSharp version is even younger

The code

Ok. That being said, we can now having a look at the code. To focus on the hexagonal architecture specificity, I recommend you to start by watching:

Hope this will clarify what Hexagonal Architecture is and how it articulates.

Clone this wiki locally