TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ready for changes with Hexagonal Architecture

117 pointsby WalterSobchakabout 5 years ago

11 comments

adamklabout 5 years ago
I came across an article a few weeks ago [1] that distils the idea of this architecture into a very simple pattern, stratified design, or the “Integration Operation Segregation Principal”:<p>“A function either integrates or operates, it either only calls other functions or it does not call other functions but contains only logic.”<p>Basically, you have code that interacts with the outside world, and you have logic (read: conditionals and branching). Don’t mix the two.<p>It’s such a simple concept that it seems obvious in hind-sight (so maybe that’s why nobody ever talks about it, because it is obvious), but I don’t see code written this way all that often.<p>If there’s one thing I could teach every new developer it would be this. It’s such a little thing, but it would make a lot of code much easier to work with.<p>[1] <a href="https:&#x2F;&#x2F;medium.com&#x2F;clean-code-development&#x2F;stratified-design-over-layered-design-125727c7e15" rel="nofollow">https:&#x2F;&#x2F;medium.com&#x2F;clean-code-development&#x2F;stratified-design-...</a>
评论 #22556694 未加载
评论 #22557227 未加载
评论 #22558895 未加载
评论 #22557195 未加载
评论 #22556030 未加载
Communitivityabout 5 years ago
I was disappointed that the article didn&#x27;t mention Alistair Cockburn, who came up with this architecture style, which is also sometimes called ports and adapters. I like hexagonal architecture a lot, but I change one aspect. Instead of Interactors I use composable Functors and Pipes. A Functor is an Interactor that takes in one Entity and produces an Entity. A Pipe is software that implements one of the different Router patterns from Enterprise Integration Patterns (<a href="https:&#x2F;&#x2F;www.enterpriseintegrationpatterns.com&#x2F;patterns&#x2F;messaging&#x2F;MessageRoutingIntro.html" rel="nofollow">https:&#x2F;&#x2F;www.enterpriseintegrationpatterns.com&#x2F;patterns&#x2F;messa...</a>). I guess you&#x27;d call what I use a hybrid of the EIP style and the Hexagonal style.
评论 #22556992 未加载
SmooLabout 5 years ago
I love the idea, and maybe this works well for them in a position of relatively lax performance.<p>The truth is that all abstractions around data fetching are inherently leaky; making an API call does _not_ have the same runtime characteristics as reading from a file. Different access patterns have different performance implications across different data sources.<p>I would love if somehow we could put runtime performance characteristics in the type systems. Implementing readFile&lt;T extends Readable, S extends SomeRuntimeCharacteristic&gt; would go a long way towards sealing those leaks.
评论 #22555318 未加载
UK-Al05about 5 years ago
People have been using this for years. One of things I recommend is not using the repository pattern. You end up with a repo with lots of methods on and overly generic.<p>For each of the use cases&#x2F;interactors, any database action should be wrapped up in a specific interface for that database action. Then implement those database interaction by implementing that interface. Query and command objects instead of repos.<p>Much finer grained then repos. Also allows for finer grained control over which data source you use for each interaction.
评论 #22556219 未加载
sischoelabout 5 years ago
Some thing I was wondering about this kind of architecture, how would you express some constrains, like foreign key constraints or unique key constraint? Would they still be in the database, or would you put them into some inner layer?
评论 #22557759 未加载
评论 #22556428 未加载
saagarjhaabout 5 years ago
I guess I’ve been staring at LLVM CMake output for too long, because I thought this had something to do with <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Qualcomm_Hexagon" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Qualcomm_Hexagon</a>
jmartricanabout 5 years ago
This architecture might bring back monoliths. Or at least it&#x27;ll bring back monolith first.
aprdmabout 5 years ago
Wonder if they have some source code examples, this also seems very similar to DDD.
评论 #22554015 未加载
评论 #22556507 未加载
评论 #22554137 未加载
评论 #22554090 未加载
评论 #22554258 未加载
michael_j_wardabout 5 years ago
If someone has some good, open source examples- please share!
duke360about 5 years ago
cool... but it is not hexagonal, it is almost quadrilateral :D :D
cheezabout 5 years ago
This sounds like something a politically astute developer came up with and built short-term career growth on it at Netflix while the rest of the developers at Netflix look on and say &quot;yeah ok but that&#x27;s just &lt;FOO METHOD&gt; drawn like a hexagaon. AM I THE ONLY ONE WHO SEES THIS ISNT SPECIAL????&quot;<p>(Because of course, I created something like this more than a decade ago that is still in use)
评论 #22554110 未加载
评论 #22554430 未加载
评论 #22555040 未加载
评论 #22558615 未加载
评论 #22554600 未加载
评论 #22554673 未加载