go-rest-api
go-rest-api copied to clipboard
Very interesting article about Clean Architecture.
Hi, Qiang! I found nice article about Clean Architecture in Golang. Did you read it? I like that the presenter extracted from Use Case layer. In our starter it hardcoded in service. And good solution, that this example fully independent from routing library. And good, that controllers are stay clean.
Thanks!
https://medium.com/manato/clean-architecture-with-go-bce409427d31
Thanks for the pointer. I just read the article and the code in the repo. I don't fully agree with some of its designs.
- The package/directory layout: the code is scattered in multiple places. It's very difficult for someone to figure out what code needs to be updated/added when implementing a new feature or usecase.
- The layout doesn't "scream" - it doesn't tell you what this project is for by just looking at the structure.
- The decoupling of controller and presenter is fine, but not always necessary. This is achieved in my project in the api layer. That is, the api layer is responsible for data transformation between input/output and those expected by the service layer. If the transformation is very complex, it is certainly a good practice to create a separate layer/class to handle them. Otherwise, creating extra layer/class just for the purpose of perfectness of the code is bad because it increases code complexity.
I do agree with what the author says in the "The only rules you need to know" section.
While designing and implementing this project, I researched nearly every repo that claims implementing the clean architecture. I found most of them try to implement the architecture in a very dogmatic way, and the end result is that they become extremely complex and thus receive little interest from practical adoption.
Yes I agree, your groupping structure is best for me. But some features from that project are useful for my opinion.
Good to hear that. Could you share what are useful and how you will use it?
Yes! Now I do refactoring all my actual projects to this new starter. I split it into microservices. When I will get some statistic I will send your my feedback.)
https://github.com/go-kit/kit/tree/master/examples/shipping
also good reference. I like how they compose an existing service into something called instrumenting service for metrics or something.
Good job everyone :)