Background
For the longest time now I have been playing with the idea of doing an application that follows the hexagonal architecture:
After reading several books on the matter, this looks like something that everyone should do. It is hard for me to find a compelling reason to not use it given that you are writing any code with a decent amount of complexity (don’t use it for an Hello World app, obviously).
However, ironically, I have never found, in all my life as a programmer, any project using it. In fact, none of my colleagues I have (or ever had) even knew about it.
What now?
So, now I have decided with my free time, to create a pet project where I can implement this architecture.
This project should be simple: It is a command line app, that makes HTTP requests to an external website.
There is no database, authentication, no nothing. Just invoking the app:
# makes a hello world search in google and IO.puts the result
./my_app --greet="hello world"
So, out of the box, I know I need an adapter for an HTTP client (lets say, HTTPoison) and a JSON decoder (lets say Jason) because I want my app to be able to change between decoders.
Questions
And this is where I freeze. There is so much stuff in my head, I can’t even start.
How should I implement the port? Via an interface (module with callbacks) like Jose Valim in hix Mox article?
http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/
What should that interface be like? Have GET and POST methods or have a “greet” method?
What about my adapters?
It really feels like that although I have read extensively about the topic, I am incapable of processing the information into something useful.
A code sample would really help.
Has any of you ever did something similar to this in Elixir?