知识卡片
对象存储库避免外部绕过规则
若数据库被设计为领域对象的存储形式,外部进程直接改写它可能绕过对象及聚合维护的不变量;外部访问还会固定表结构,使对象重构更难同步。原书因此建议这种存储库不向对象系统之外开放直接访问。此建议有前提:若数据库本来还供其他软件使用,就须另外设计双方的模型与契约。参见[[聚合内不变量随事务检查]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Designing Objects for Relational Databases · 查看原书依据
Processes outside the object system should not access such an object store. They could violate the invariants enforced by the objects. Also, their access will lock in the data model so that it is hard to change when the objects are refactored.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第47章《原书第06章|Designing Objects for Relational Databases》(源文件:_epub-src/0321125215_ch06lev1sec4.html)
- 结论依据:原文指出外部程序访问对象存储会破坏对象不变量,并锁定数据模型、妨碍对象重构;后段说明多软件共用数据库属于不同情形。
- 原始内容:Processes outside the object system should not access such an object store. They could violate the invariants enforced by the objects. Also, their access will lock in the data model so that it is hard to change when the objects are refactored.