Are Repositories Domain Model Objects?
来源:互联网 发布:nginx lbs lua 编辑:程序博客网 时间:2024/06/04 17:51
I focus on DDD for a long time,and I am working on an open source project with DDD now.Recently,I am thinking about the repository.I reffered to DDD Sample Project,I noticed that: repositories are placed in "domian.model" package. I deliberated repository again, I think we should not regard it as a part of domain model! The reasons as below:
1.From pure domain view,there is no "repository" conception.It looks like a "programming-specific" mechanism more .For example: in the "domain.model.cargo" package of DDDSample,The cargo,delivery or itinerary,they are all looks good,because they are "real role" in domain model,howerver,the CargoRepository looks weird, they may make domain experts confused!
2.I also admit that: Repository make sense for domain model.we indeed need a role which represents a collection of domain objects and provides CRUD service.however,no matter how to emphasis this role's "domain property",it still have to get involved in data acess logic!If we regard this role as a part of domain medel,the data access logic may "pollute" domain model!For example: in DDDSample,designers place repository interface in domain.model package,however,designers themself are also aware of their hibernate implement classes should not be placed in "domain.model",so,they placed them in infrastructure package.Why interface and its implement class are so different that make them so estranged?They shouldn't be such relationship!The source of problem is like what I mentioned:Even though it is only an inerface in domain model,repositories have to deal with data access logic,this is their inherent responsbility!Interface can not conceal it.
So,I think it is not suitable to place repositories in domain model.We all know:For creating a clean domain model,domain model object should not depend on any service or repository.Actually,repositories are only invoked by service when they want to persist aggregation root.
So,I think we should regard repositories as a special kind of domain object,It only works on aggregate roots,and invoked by service when aggregate roots need persistence.And finally,I think it is better if we place repositories in such package:"domain.repository" that stand "domain.model" and "domain.service" side by side!
Be careful:The package name is "domain.repository" not "dataaccess.repository" or "persistence.repository"!Repository is a sepical domain object like service!This is my opinion!
- Are Repositories Domain Model Objects?
- Domain Model
- Domain Model 探索
- 领域模型(Domain Model )
- Why Domain Model Design ?
- 领域模型(Domain Model )
- 初始化domain model
- 探索Domain Model系列
- Domain Model 使用注意
- [系分] Domain Model
- Business Domain & Domain Model & Domain Model Oriented Archtecture
- Model confusion : Domain Model & E-R Model
- 3 When Objects are Alike
- PEAA笔记二:Domain Model
- 小议领域模型(Domain Model)
- 域模型(Domain Model)
- Domain Model Analysis and Design
- When Are WDM Device Objects Created?
- 关于防止sql注入的几种手段
- div 显示与隐藏
- [快乐Android4]Android SDK
- 管理类业务系统菜单部分美化经验分享,把所有好的东西拿过来拼凑并不容易能形成整体的效果
- 能盖住Select的Div
- Are Repositories Domain Model Objects?
- Vmware 实验网搭建
- 科学的特性与中医理论的基础 作者:奥卡姆剃刀
- 反正切三角函数的c源代码
- asp.net 生命周期 给控件传值 注意
- 利用Winsock控件实现局域网通信
- 结构体的部分初始化
- 正则基础之 NFA引擎匹配原理
- 个人职业提升需要跨越性思维