当前位置:网站首页>DDD application and practice of domestic hotel transactions -- Code
DDD application and practice of domestic hotel transactions -- Code
2022-07-04 14:13:00 【InfoQ】
One 、 Four floors are used for hotel transactions DDD Loose architecture

- User interface layer : The user interface layer is only used for processing user display and rendering of user requests and data , Should not contain domain or business logic ( Business logic is clearly defined in domain design 、 Business refers to the process that a process or behavior or an action must produce to promote the next behavior or action , Page rendering 、 The retrieval class does not belong to business logic );
- application layer : Application services are located in the application layer . Application services are used to control persistent transactions and security authentication . Application services themselves do not handle business logic , Application services are lightweight , It is mainly used to coordinate the operation of domain objects , The common use of application services is : Receive input parameters from the user interface , Then get the aggregation instance through the resource library , Then execute the corresponding command operation ;
- Domain layer : Or model layer , Be responsible for expressing business concepts, business status information and business rules . This area ( Problem domain ) Complete all complex business knowledge abstractions and rule definitions ;
- Infrastructure layer : One is to provide persistence mechanism for domain model ;
Two 、DDD Implementation and code implementation

1、 Building a common language for hotel transactions

2、 Four layer architecture code implementation
2.1 User interface layer code implementation example ( Order )

2.2 Application layer code implementation example ( Order )

2.3 Domain layer code implementation example ( Order )
- Aggregate root It's an entity , With unique identification , There's a separate life cycle , An aggregate has only one aggregate root , The aggregation root is responsible for organizing and coordinating changes to entities and value objects within the aggregation , It is not allowed to bypass the aggregation root and directly access entities in the aggregation for interaction , This will cause the aggregation to be in an inconsistent state , Violate the principle of aggregation invariance , There are certain principles to follow when designing aggregation roots ;
- Aggregate root to aggregate root : adopt ID relation ;
- Aggregate the root to its internal entity , Direct object reference ;
- Aggregate root to value objects , Direct object reference ;
- Expose behavioral interfaces Show the expression of domain concepts , As the entrance of external communication , Only the aggregation root can be accessed externally , The aggregation root maintains the internal consistency of the aggregation ;
- Domain services represent a stateless operation , It is used to implement tasks specific to a certain field . When an action does not fit on an aggregate object , You can use domain services .


- Unique identification
- Life cycle has state
- Reflect relevant business behaviors

2.4 Resource layer code implementation example
- 【 The principle of consistency 】
- 【 Keep the same conditions 】
- 【 A transaction modifies only one aggregate 】
- 【 Little aggregation 】






Summary
- Hotel transaction common language construction display
- User interface layer code implementation 、
- Application layer code implementation and principles ;
- Order aggregation root code implementation 、 How to ensure consistency in aggregation 、 Factory code implementation example
- Fund entity code implementation
- Order warehousing code implementation 、 Warehouse level method definition standard
- Consistency principle between aggregations and code implementation 、 How to ensure the consistency of multiple aggregations
边栏推荐
- [antd] how to set antd in form There is input in item Get input when gourp Value of each input of gourp
- MySQL之详解索引
- 数据仓库面试问题准备
- Mask wearing detection based on yolov1
- Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?
- Hardware Basics - diode Basics
- Understand chisel language thoroughly 10. Chisel project construction, operation and testing (II) -- Verilog code generation in chisel & chisel development process
- R语言使用dplyr包的group_by函数和summarise函数基于分组变量计算目标变量的均值、标准差
- Can mortgage with housing exclude compulsory execution
- CVPR 2022 | greatly reduce the manual annotation required for zero sample learning, and propose category semantic embedding rich in visual information (source code download)
猜你喜欢

The font of markdown grammar is marked in red

Unity shader learning (3) try to draw a circle

Understand chisel language thoroughly 06. Chisel Foundation (III) -- registers and counters

Deming Lee listed on Shenzhen Stock Exchange: the market value is 3.1 billion, which is the husband and wife of Li Hu and Tian Hua

【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结

China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder

2022 hoisting machinery command examination simulation 100 questions simulation examination platform operation

学内核之三:使用GDB跟踪内核调用链

Product identification of intelligent retail cabinet based on paddlex

Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?
随机推荐
测试流程整理(3)
FS4059C是5V输入升压充电12.6V1.2A给三节锂电池充电芯片 输入小电流不会拉死,温度60°建议1000-1100MA
CVPR 2022 | greatly reduce the manual annotation required for zero sample learning, and propose category semantic embedding rich in visual information (source code download)
忠诚协议是否具有法律效力
華昊中天沖刺科創板:年虧2.8億擬募資15億 貝達藥業是股東
Automatic filling of database public fields
IDEA快捷键大全
Gorm read / write separation (rotation)
Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?
苹果5G芯片研发失败:继续依赖高通,还要担心被起诉?
好博医疗冲刺科创板:年营收2.6亿 万永钢和沈智群为实控人
go vendor 项目迁移到 mod 项目
做事的真正意义和目的,真正想得到什么
IP lab monthly resumption · issue 5
BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
Worried about "cutting off gas", Germany is revising the energy security law
【Antd踩坑】Antd Form 配合Input.Group时出现Form.Item所占据的高度不对
Huahao Zhongtian sprint Technology Innovation Board: perte annuelle de 280 millions de RMB, projet de collecte de fonds de 1,5 milliard de Beida Pharmaceutical est actionnaire
Variable promotion and function promotion in JS
小程序直播 + 电商,想做新零售电商就用它吧!