文档章节

Are Repositories Domain Model Objects?

猪刚烈
 猪刚烈
发布于 2014/10/12 11:40
字数 392
阅读 38
收藏 0

「深度学习福利」大神带你进阶工程师,立即查看>>>

 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!

猪刚烈

猪刚烈

粉丝 22
博文 708
码字总数 110
作品 1
海淀
程序员
私信 提问
加载中
请先登录后再评论。
DNS服务器软件--BIND 10

BIND 10 是下一代的 Bind 。 Bind是一款开放源码的DNS服务器软件,Bind由美国加州大学Berkeley分校开发和维护的,全名为Berkeley Internet Name Domain它是目前世界上使用最为广泛的DNS服务器...

匿名
2013/02/22
3.7K
1
Password Manager Daemon

pwmd(Password Manager Daemon) 通过 Unix domain socket 提供服务,数据存储在加密的 XML 文件中,客户端必须提供密钥才能修改。支持多线程,可同时允许多个客户端同时连接。 特性 通过 ...

匿名
2013/03/12
431
0
Go 的 Web 框架--Golanger

Golanger 是一个轻量级的 Web 应用框架,使用 Go 语言编写。 Golanger框架主要实现了MVC模式(三层架构模式)(Model-View-Controller), 它是软件工程中的一种软件架构模式,把软件系统分为三个...

余风11
2012/11/23
9.1K
1
Web服务器--Gatling Web Server

Gatling,格林机关枪一样的高效轻量级WEB SERVER,优点是精简高效,完全免配置,支持HTTP/FTP/SMB等协议,支持CGI/FASTCGI,还附带了几个有用的webbench测试工具,非常贴心。 特性: 体积小,...

匿名
2012/12/15
1.4K
0
GObjects 预处理器--GOB

GObject Builder (GOB) 是一个用来轻松创建 GObjects (glib objects) 的简单预处理器。它读取 C 代码中的类描述文件并生成 .c 和 .h 的文件。可以让你使用大多数 GObject 系统而大大减少编码...

匿名
2012/12/20
669
0

没有更多内容

加载失败,请刷新页面

加载更多

箭头翻转效果

vue实现点击箭头的旋转动画(收起展开)效果 https://blog.csdn.net/Rampage_w/article/details/106496646?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~all~first_ra......

花乐天
31分钟前
0
0
预告 | 一场解决SSL/TLS证书困局的硬核发布会

大数据时代,信息安全威胁日益严峻,国内国际(等保2.0 、密码法、GDPR等)法规的出台,使得数据安全和隐私保护愈加被高度重视, SSL 证书作为互联网的安全标签,需求量日益增加,已然成为企...

osc_q5m9dzk0
31分钟前
19
0
提高数据处理效率的excel小技巧(一)

转自:求知鸟 作者:求知鸟 这是一个技巧贴,直接上干货: 1、你想在excel中看到函数值是如何计算出来的? Ctrl+~:进入函数视图 2、去除重复值方式有哪些? a、数据—数据工具—删除重复值(...

朱小五
昨天
0
0
全网疯传,50个精选BAT等大厂大数据、算法落地经验,白拿不谢!

话不多说,直接上干货资料,我们精选了50个百度、腾讯、阿里等大厂的大数据、算法落地经验,分享给大家: 识别二维码,回复"大厂经验",获取PDF干货合集! 合集目录: 识别二维码,回复"大厂...

BBuf
今天
11
0
小白写论文 | 技术性论文结构剖析

【前言】:公众号的AI初学者交流群已经建立啦,公众号后台回复【加群】可以加入。群里都是些一起学习的朋友,大家学习路上,结个伴。 【公众号资源汇总】:炼丹图书馆 | AI初学者所需要的资料...

机器学习炼丹术
昨天
0
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部