Why DDD?
The following are the reasons to consider using DDD:
Provide principles & patterns to solve difficult problems
Base complex designs on a model of the domain
Initiate a creative collaboration between technical and domain experts to iteratively refine a conceptual model that addresses domain problems.
DDD comprises of 4 Layers
http://dddsample.sourceforge.net/architecture.html
Domain: This is where the domain and business logic of the application is defined.
Infrastructure: This layer consists of everything that exists independently of our application: external libraries, database engines, and so on.
Application: This layer serves as a passage between the domain and the interface layer. The sends the requests from the interface layer to the domain layer, which processes it and returns a response.
Interface: This layer holds everything that interacts with other systems, such as web services, RMI interfaces or web applications, and batch processing frontends.
image.png
layout




summary=>4层分层架构
go-ddd-sample分为application、domain、infrastructure、interfaces四层,其中domain定义repository接口,infrastructure层实现该接口,application层通过domain来编排业务逻辑,interfaces层则基于net/http来提供http接口。


code
https://dev.to/stevensunflash/using-domain-driven-design-ddd-in-golang-3ee5
https://github.com/victorsteven/food-app-server
ref
https://segmentfault.com/a/1190000039397677
https://blog.csdn.net/hello_ejb3/article/details/115106619
https://github.com/takashabe/go-ddd-sample
网友评论