Hexagonal Architecture

An implementation guide


Chapter 3: DEVELOPMENT SEQUENCE

Next Chapter

Published on April 13, 2021 by Juan Manuel Garrido de Paz

TABLE OF CONTENTS

  1. Introduction
  2. Hardcoded hexagon
  3. The hexagon in isolation
  4. Adding real adapters
  5. Links

1.- INTRODUCTION

This is the third article of a series showing how to implement an application according to Hexagonal Architecture, also known as Ports and Adapters pattern, whose author is Dr. Alistair Cockburn.

So far we have seen the application design (Chapter 1) and structure (Chapter 2). As a result of the design, we got two things:

Figure 1: The big picture

Figure 1: The big picture

From these two things, we will begin to implement the different modules of the architecture, following a development sequence.

According to Alistair Cockburn (see for example his talk about Hexagonal Architecture at Agiles2020 conference), this development sequence would have some stages:

STAGE DRIVER SIDE HEXAGON
(APPLICATION)
DRIVEN SIDE
(S1) Test cases Hardcoded -
(S2) Test cases Real Test doubles
(S3) Real Real Test doubles
(S4) Test cases Real Real
(S5) Real Real Real

We can see that we start with test harness at both sides: first on the left side (S1) and then on the right side (S2).

From that moment on, we add real adapters at both sides: first we change left side technology (S3) and then we change right side technology (S4).

So that finally we get the application running in a production environment with real adapters at both sides (S5).

Some important things to remark:

2.- HARDCODED HEXAGON

In this section we will see the first stage in the development sequence: “Test Cases + Hardcoded Hexagon”.

Source code for this stage is available at stage1 tag in BlueZone GitHub Repository.

Figure 2: First development stage: Test Cases + Hardcoded Hexagon

Figure 2: First development stage: Test Cases + Hardcoded Hexagon

We have these modules:

README.md file at BlueZone GitHub repository explains how to run the application.

Here you can see screen-shots of HTML reports, generated after running test cases:

Figure 3: "for parking cars" test HTML report, generated by Cucumber

Figure 3: "for parking cars" test HTML report, generated by Cucumber

Figure 4: "for checking cars" test HTML report, generated by TestNG

Figure 4: "for checking cars" test HTML report, generated by TestNG

In the next stage we implement test doubles as adapters on the right side.

Let’s see.

3.- THE HEXAGON IN ISOLATION

TODO ASAP

4.- ADDING REAL ADAPTERS

TODO

https://jmgarridopaz.github.io/content/resources.html

https://cucumber.io/

https://en.wikipedia.org/wiki/Behavior-driven_development

https://beyondxscratch.com/2019/05/21/behavior-driven-development-from-scratch/

https://beyondxscratch.com/2019/08/26/implementing-functional-tests-in-domain-driven-design-hexagonal-architecture-using-cucumber-domain-driven-testing/

https://testng.org/doc/