I had a great time chatting to Greg Shackles and Jon Dick as we recorded an episode of Gone Mobile podcast recently, exploring some themes around a blog post I wrote on Hexagonal Architecture for mobile applications.
I came away from it having really enjoyed the experience, but wishing i’d done a better job in communicating some of the points I wanted to get across. Below are a few things I’d like to follow up on. If you haven’t already, i’d suggest you listen to the show and check out the original post first before reading on:
Naming is hard
It turns out even talking about naming is hard. When asked whether I would go so far as to use terms like ports and adapters throughout a codebase, my answer was basically ‘it depends’, although I didn’t do a very good job of explaining why.
My reasoning here is, that many of the situations we discussed were instances where a team has already built an application with layers in mind and subsequently discovers that this type of architecture better describes what they’ve ended up with. Would I go back and rename everything at this point on an established project? Not unless there was a strong feeling throughout the team that it was of benefit.
On a new project, I would definitely use those terms. However, it’s important to consider that the term adapter means something very specific in Android, so you need to be careful to avoid confusion. PortAdapters is one alternative that I have used, but i’m not entirely satisfied with it. Naming is hard and it’s going to come down to personal preference.
Why am I still talking about hexagons?
I made the point that the hexagon isn’t important. There are plenty of variations and really it’s all about where the dependencies point and putting the domain model at the centre of your architecture. I also pointed out that Alistair Cockburn himself says he prefers the term Ports and Adapters.
So why am I still talking about hexagons?
Well my personal view is that Hexagonal Architecture is still the most commonly used term for this type of design. It is the form in which I first learned about this approach and feel most comfortable talking about. I disagree with Cockburn on this one, and think Hexagonal Architecture is a great name. It immediately triggers a vision of the central hexagon housing the all-important core application and offering up its sides for configuration. I’ll continue to use that term.
There are always at least two configurations
Greg asked whether I would apply this architecture in scenarios where there is no need to share code across multiple platforms. My reply focussed on what I’ve done in the past, but failed to make the point that with your integration tests, you always have at least two configurations to consider. To some extent, this nullifies any argument about whether you need to be sharing code to get the benefit of this approach.
I will write that follow-up article
Although I talked of some ideas I had about taking the concept further, I was sketchy on whether there will be any follow up content. However, having heard two guys as talented as Greg and Jon speaking so positively about what i’d done and keen to read more, I couldn’t help but be inspired!
It was great to have been involved with Gone Mobile. I’m now exploring the other 29 episodes in the show’s archives and looking forward to those still to come. I suggest you take a look at the Gone Mobile catalogue too!