Please enable JavaScript.
Coggle requires JavaScript to display documents.
DEVOXX 2018 : Hexagonal Architecture & Functional Programming (:bulb…
DEVOXX 2018 :
Hexagonal Architecture
& Functional Programming
:pen:
Principle of
Hexagonal
Architecture
Application Programming Interface
The set of services you offer to the world
Isolate domain from real world
to protect domain logic from change of technologies
Service Provider Interfaces
State your dependencies in terms of service required from the outside world
:warning:
Drawbacks of
OOP approach
Not that safe, and not declarative
Easy to hack through and introduce a dependency in the implementation
Heavy dependency injection
: often resort to framework - which is somehow something you would want to abstract from your domain as well
Going further:
Layers of Monads
Pick your Monads
You can even use a Free Monad behind the interface to emit instructions (modify instructions - optimize them - combine them with another program)
Layering of dependencies = layering of ASM for your domain
A Monad can be implemented in terms of another Monad, down to the IO Monad (effectful one)
A Monad-based
FP approach
:pen:
What is a Monad
Just a specific environment of execution in which the semantic of the semi-colon is modified to include some more stuff (composition of effect)
Define ASM of your domain
The bricks of side effects you can use to connect to external world
Typical OOP
implementation
:warning:
Often the implementation is mixed up with the notions
I even heard someone resume Port/Adapter to Interfaces in a presentation on Hexagonal Architecture
Use interfaces
to inject the dependencies to the SPI
Publish interface
for the service delivered by your API
:bulb:
Easy recipe for
your domain
One type-class method for each function
Add a Monad to the mix
Then just write code...
Add Monad implementation to the real world
Add Monad implementation to fake world (in memory DB)