Languages: English | 中文
DDDplus, originally cp-ddd-framework(cp means Central Platform:中台), is a lightweight flexible development framework for complex business architecture.
DDDplus是轻量级、对DDD进行补充和增强的框架,提供的核心内容包括:
- 扩展点机制,支持复杂场景问题
- 扩充了DDD的building blocks,解决DDD落地难问题
- 基于代码进行人工DSL标注的逆向建模机制,领域知识模型化
具体内容:
- 确定性问题
- IBag,封装集合逻辑
- (IRule, IBehavioralRule,IDefinitionalRule),业务规则对象
- (IUnboundedDomainModel, BoundedDomainModel),上下文角色对象
- (DirtyMemento, IDirtyHint, IMergeAwareDirtyHint),追踪领域对象状态变化,通过乐观锁实现落库
- Exchange,domain与infrastructure间传递非领域数据的容器
- ISpecification,业务校验和场景识别
- INativeFlow,可复用的流程片段
- AbstractBusinessNo,业务编号建模
- IUnitOfWork,跨聚合根的事务
- 不确定问题
- IDomainExtension,扩展点
- IIdentity,业务身份
- (Policy, Router),扩展点的两种路由方式
- Pattern,全局业务模式
- Interceptor,扩展点拦截器
- 进程外依赖
- IGateway,远程RPC的防腐层
- IRepository,数据持久化
- 技术组件
- mapstruct,对象转换
- 架构守护
- DDDPlusEnforcer,业务建模规范的架构守护
- 可视化逆向建模
- (DomainModelAnalyzer, PlantUmlBuilder), 分析Java AST自动生成逆向业务模型
Used for several complex critical central platform projects in production environment.
<dependency>
<groupId>io.github.dddplus</groupId>
<artifactId>dddplus-runtime</artifactId>
</dependency>
@SpringBootApplication(scanBasePackages = {"${your base packages}", "io.github.dddplus"})
public class WebApplication {
public static void main(String[] args) {
SpringApplication.run(WebApplication.class);
}
}
Pattern
/Partner
/Policy
,都是Extension#code
的提供者(它们有的通过match(IIdentity)
方法,有的通过extensionCode(IIdentity)
方法),即准入规则,本质上都是把动态的业务场景转换为静态的Extension#code
,而Extension#code
被扩展点实例通过注解绑定,从而实现了扩展点的动态路由。
之所以设计成这样的间接路由,是基于平台强管控
原则。
<dependency>
<groupId>io.github.dddplus</groupId>
<artifactId>dddplus-visualization</artifactId>
</dependency>
通过DSL在代码进行标注后,即可自动PlantUML类图形式的业务模型:
class ReverseModelingTest {
@Test
void reverseModeling() {
DomainModelAnalyzer domainModelAnalyzer = new DomainModelAnalyzer();
ReverseEngineeringModel domainModel = domainModelAnalyzer.scan("{your module root}")
.analyze();
new PlantUmlBuilder()
.build(domainModel)
.renderSvg("myModel.svg");
}
}
为了避免错误使用造成的线上事故,建议CI流水线里增加DDDplus的错误使用卡控。
<dependency>
<groupId>io.github.dddplus</groupId>
<artifactId>dddplus-enforce</artifactId>
<scope>test</scope>
</dependency>
通过单测执行DDDplus enforcement:
public class DDDPlusEnforcerTest {
@Test
public void enforce() {
DDDPlusEnforcer enforcer = new DDDPlusEnforcer();
enforcer.scanPackages("${your base package}")
.enforce();
}
}
You are welcome to contribute to the project with pull requests on GitHub.
If you find a bug or want to request a feature, please use the Issue Tracker.
For any question, you can use Gitter Chat to ask.
DDDplus is licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.