当前位置:网站首页>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
边栏推荐
- 吃透Chisel语言.09.Chisel项目构建、运行和测试(一)——用sbt构建Chisel项目并运行
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.col参数指定强调线的id子集的颜色(色彩)
- MySQL5免安装修改
- Fs4059c is a 5V input boost charging 12.6v1.2a. Inputting a small current to three lithium battery charging chips will not pull it dead. The temperature is 60 ° and 1000-1100ma is recommended
- 硬件基础知识-二极管基础
- Gorm read / write separation (rotation)
- C language programming topic reference
- 1200. 最小绝对差
- Assertion of unittest framework
猜你喜欢
瑞吉外卖笔记
华昊中天冲刺科创板:年亏2.8亿拟募资15亿 贝达药业是股东
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
392. 判断子序列
Unittest框架中引入TestFixture
锐成芯微冲刺科创板:年营收3.67亿拟募资13亿 大唐电信是股东
Product identification of intelligent retail cabinet based on paddlex
JVM memory layout detailed, illustrated, well written!
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
1200. Minimum absolute difference
随机推荐
Ws2818m is packaged in cpc8. It is a special circuit for three channel LED drive control. External IC full-color double signal 5v32 lamp programmable LED lamp with outdoor engineering
英视睿达冲刺科创板:年营收4.5亿 拟募资9.79亿
Gorm data insertion (transfer)
【Antd踩坑】Antd Form 配合Input.Group时出现Form.Item所占据的高度不对
Gorm 读写分离(转)
[FAQ] Huawei Account Service Error Report 907135701 Common reasons Summary and Solutions
读取 Excel 表数据
【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结
golang fmt.printf()(转)
qt 怎么检测鼠标在不在某个控件上
2022 hoisting machinery command examination simulation 100 questions simulation examination platform operation
测试流程整理(3)
php 日志调试
Blob, text geometry or JSON column'xxx'can't have a default value query question
JVM memory layout detailed, illustrated, well written!
華昊中天沖刺科創板:年虧2.8億擬募資15億 貝達藥業是股東
[R language data science]: cross validation and looking back
Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?
Common content type correspondence table
学习项目是自己找的,成长机会是自己创造的