Git Product home page Git Product logo

go-ddd-tavern's Introduction

小酒馆的DDD实践

参考资料:

  1. How To Implement Domain-Driven Design (DDD) in Golang
  2. Github Code

定义

实体:具有唯一标识的对象,可变的

值对象:没有唯一标识的对象,不可变。比如一单交易执行了,它就不能改变状态了

聚合:实体和值对象的组合集,存储在存储库

设计

flowchart LR

subgraph 实体
item[物品]
person[人]
end

subgraph 值对象
transaction[交易]
end

subgraph 聚合
customer[顾客]
product[商品]
end

subgraph 应用
order[订单]
tavern[小酒馆]
end

item --> product
person --> customer
transaction --> customer

product --> order
customer --> order

order --> tavern

实现

实现过程:domain --> infrastructure --> application --> interface

domain

实现顺序:实体 --> 值对象 --> 聚合

infrastructure

domain中定义 repository 接口,然后在infrastructure中实现这些接口

总结

能够把基本流程走一遍,但依然有这几个问题:

  1. insfrastructure中的实现,现在还是比较单一的,理论上能抽象下
  2. 这个结构还是需要优化的,还是比较别扭的
  3. trasaction也没有被使用到

go-ddd-tavern's People

Contributors

stoneren avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.