当前位置:网站首页>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
边栏推荐
- Detailed explanation of Fisher information quantity detection countermeasure sample code
- R语言dplyr包summarise_if函数计算dataframe数据中所有数值数据列的均值和中位数、基于条件进行数据汇总分析(Summarize all Numeric Variables)
- 数据仓库面试问题准备
- 2022 practice questions and mock exams for the main principals of hazardous chemical business units
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用stress.col参数指定强调线的id子集的颜色(色彩)
- 吃透Chisel语言.12.Chisel项目构建、运行和测试(四)——Chisel测试之ChiselTest
- Install and use MAC redis, connect to remote server redis
- [C question set] of VII
- 30: Chapter 3: develop Passport Service: 13: develop [change / improve user information, interface]; (use * * * Bo class to accept parameters, and use parameter verification)
- Code hoof collection of wonderful secret place
猜你喜欢
![[antd] how to set antd in form There is input in item Get input when gourp Value of each input of gourp](/img/eb/11e5da1c5e897c5f6a18d49125925f.png)
[antd] how to set antd in form There is input in item Get input when gourp Value of each input of gourp

MySQL之详解索引

392. 判断子序列

小程序直播 + 电商,想做新零售电商就用它吧!

基于PaddleX的智能零售柜商品识别

One of the solutions for unity not recognizing riders

The font of markdown grammar is marked in red

自主工业软件的创新与发展

【FAQ】華為帳號服務報錯 907135701的常見原因總結和解决方法

2022 practice questions and mock exams for the main principals of hazardous chemical business units
随机推荐
JVM memory layout detailed, illustrated, well written!
Understand chisel language thoroughly 05. Chisel Foundation (II) -- combinational circuits and operators
R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用by参数指定分组参数可视化不同分组的点图分布
GCC【6】- 编译的4个阶段
Basic mode of service mesh
Understand chisel language thoroughly 10. Chisel project construction, operation and testing (II) -- Verilog code generation in chisel & chisel development process
China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder
吃透Chisel语言.04.Chisel基础(一)——信号类型和常量
ARouter的使用
R语言使用dplyr包的group_by函数和summarise函数基于分组变量计算目标变量的均值、标准差
[matlab] summary of conv, filter, conv2, Filter2 and imfilter convolution functions
Ws2811 m is a special circuit for three channel LED drive and control, and the development of color light strip scheme
How to choose a technology stack for web applications in 2022
QT how to detect whether the mouse is on a control
基于YOLOv1的口罩佩戴检测
Install and use MAC redis, connect to remote server redis
Excel快速合并多行数据
[C question set] of VII
Whether the loyalty agreement has legal effect
C# wpf 实现截屏框实时截屏功能