当前位置:网站首页>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 step pit] antd form cooperates with input Form The height occupied by item is incorrect](/img/96/379d1692f9d3c05a7af2e938cbc5d7.png)
[antd step pit] antd form cooperates with input Form The height occupied by item is incorrect

吃透Chisel语言.10.Chisel项目构建、运行和测试(二)——Chisel中生成Verilog代码&Chisel开发流程

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

Apple 5g chip research and development failure: continue to rely on Qualcomm, but also worry about being prosecuted?

华昊中天冲刺科创板:年亏2.8亿拟募资15亿 贝达药业是股东

好博医疗冲刺科创板:年营收2.6亿 万永钢和沈智群为实控人

Understand chisel language thoroughly 09. Chisel project construction, operation and testing (I) -- build and run chisel project with SBT

MySQL version 8 installation Free Tutorial

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

数据仓库面试问题准备
随机推荐
Gorm read / write separation (rotation)
Test evaluation of software testing
golang fmt. Printf() (turn)
Understand chisel language thoroughly 04. Chisel Foundation (I) - signal type and constant
Dgraph: large scale dynamic graph dataset
Idea shortcut keys
qt 怎么检测鼠标在不在某个控件上
Understand chisel language thoroughly 05. Chisel Foundation (II) -- combinational circuits and operators
Install and use MAC redis, connect to remote server redis
Mask wearing detection based on yolov1
LiveData
Hardware Basics - diode Basics
吃透Chisel语言.11.Chisel项目构建、运行和测试(三)——Chisel测试之ScalaTest
Variable promotion and function promotion in JS
BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
【R语言数据科学】:交叉验证再回首
R语言使用dplyr包的mutate函数对指定数据列进行标准化处理(使用mean函数和sd函数)并基于分组变量计算标准化后的目标变量的分组均值
MySQL 5 installation and modification free
[matlab] summary of conv, filter, conv2, Filter2 and imfilter convolution functions
TestSuite and testrunner in unittest