当前位置:网站首页>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
边栏推荐
- [FAQ] Huawei Account Service Error Report 907135701 Common reasons Summary and Solutions
- Install MySQL
- Doctoral application | West Lake University Learning and reasoning system laboratory recruits postdoctoral / doctoral / research internship, etc
- 读取 Excel 表数据
- IDEA快捷键大全
- Excel快速合并多行数据
- Assertion of unittest framework
- 安装Mysql
- 锐成芯微冲刺科创板:年营收3.67亿拟募资13亿 大唐电信是股东
- 【Antd踩坑】Antd Form 配合Input.Group时出现Form.Item所占据的高度不对
猜你喜欢
Introducing testfixture into unittest framework
JVM memory layout detailed, illustrated, well written!
MySQL之详解索引
華昊中天沖刺科創板:年虧2.8億擬募資15億 貝達藥業是股東
[matlab] summary of conv, filter, conv2, Filter2 and imfilter convolution functions
小程序直播 + 电商,想做新零售电商就用它吧!
Interviewer: what is the internal implementation of hash data type in redis?
使用默认路由作为指向Internet的路由
MySQL5免安装修改
锐成芯微冲刺科创板:年营收3.67亿拟募资13亿 大唐电信是股东
随机推荐
Code hoof collection of wonderful secret place
R语言ggplot2可视化:gganimate包创建动画图(gif)、使用anim_save函数保存gif可视化动图
中邮科技冲刺科创板:年营收20.58亿 邮政集团是大股东
学习项目是自己找的,成长机会是自己创造的
安装Mysql
gorm 之数据插入(转)
Detailed explanation of Fisher information quantity detection countermeasure sample code
MySQL8版本免安装步骤教程
Doctoral application | West Lake University Learning and reasoning system laboratory recruits postdoctoral / doctoral / research internship, etc
[antd] how to set antd in form There is input in item Get input when gourp Value of each input of gourp
MongoDB常用28条查询语句(转)
php 日志调试
MySQL version 8 installation Free Tutorial
find命令报错: paths must precede expression(转)
Understand chisel language thoroughly 12. Chisel project construction, operation and testing (IV) -- chisel test of chisel test
【R语言数据科学】:交叉验证再回首
golang fmt.printf()(转)
Dgraph: large scale dynamic graph dataset
BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法