back to listing index

The Clean Architecture: In Practice · Marconi Moreto Jr.

[web search]
Original source (
Tags: golang go clean-architecture anti-patterns
Clipped on: 2015-01-29

The Clean Architecture: In Practice

Sat, Dec 27, 2014

UPDATE Dec. 30, 2014

I realized that with the interface being required by a layer on the outer layer, it makes the relationship a bit unclear. So I moved them down one layer so its clear that a layer can’t referenced anything from the outside. ie. moving TodoAdapter interface from interfaces layer to domains layer. Note that these changes doesn’t break our tests since they all live on the same package. I updated the source code below as well as the one on github.

I’ve had my fair share of headaches when dealing with spaghetti codes, codes other developers have written and even code I wrote. Most of the time I told myself I wish I could rewrite everything from scratch, and indeed for personal projects, sometimes I did just that. But that’s not always possible, nor is it always the right way.

Like most startups, we have a fair bit of technical debt and in the last few months my job has been mostly focused on rewriting components and dealing with some of these technical debts. Given a reasonable amount of time thinking about a problem, one will eventually find better solutions on how to do things. But as you continue to write all these new code, it can quickly start to feel like its the same mess all over again.

This leads me down the path of seeking for better ways to structure and write software, I needed something that’s maintainable in the long run, easily testable, decoupled and introduces low barrier for developers trying to learn how the code works. Then I came across The Clean Architecture, which isn’t new, there exists several similar approaches but I was enlightened by how each layer easily made sense.

Image (Asset 1/2) alt=