文档章节

Are Repositories Domain Model Objects?

猪刚烈
 猪刚烈
发布于 2014/10/12 11:40
字数 392
阅读 10
收藏 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!

本文转载自:http://blog.csdn.net/bluishglc/article/details/4867268

共有 人打赏支持
猪刚烈
粉丝 22
博文 708
码字总数 110
作品 1
海淀
程序员
DDD: Part I (Introduction)

The first time I heard about DDD (Domain Driven Design, not Deadline Driven Design, for sure), I was still working as a Senior Java Developer for Hewlett-Packard at its Developm......

M Yauri Maulana at-Tamimi
2017/12/14
0
0
JSON反序列化库--Upida

Upida 是一个轻量级的库,主要的目的是反序列化 JSON 数据到域对象。实现了: Assigns back-references to domain objects. Copies data from MVC model to persistent objects (with no cus...

红薯
2014/03/04
286
0
centos5.6 gitolite-admin 问题,求助

git.exe push -v --progress "origin" master:master Pushing to git@118.145.14.172:repositories/gitolite-admin Counting objects: 15, done. Compressing objects: 100% (10/10) Writing......

橙汁儿
2012/01/06
718
0
领域驱动设计(DDD)框架--Synopse mORMot framework

Synopse mORMot framework, 原名Synopse SQLite3 Framework 。是一个Client-Server ORM和SOA框架,适用Delphi6到XE4,Win32或Win64. 可以创建从独立方案到复杂的领域驱动设计: 表示层 MVC ...

炽火
2013/12/03
4K
3
目标跟踪简述+深度学习目标跟踪+context目标跟踪

Visual Tracking With Deep Learning And The Context 一. The overview of Visual Tracking 目标跟踪简介 1. What is visual tracking? This three pictures are the 1,40,80 frame of the......

BookThief
2017/09/21
0
0

没有更多内容

加载失败,请刷新页面

加载更多

nginx的简单使用:负载均衡

nginx:反向代理的服务器;用户发送请求到nginx,nginx把请求发送给真正的服务器,等待服务器处理完数据并返回,再把数据发送给用户。 nginx作为一个反向代理服务器,能缓存我们项目的静态文...

osliang
12分钟前
1
0
网站title标题被改并被百度网址安全中心提醒的解决办法

国庆假日期间我们Sine安全接到众多网站站长求助网站标题被改导致在百度搜索中百度安全中心提醒被拦截,导致网站正常用户无法浏览网站被跳转到一些菠菜du博网站,而且很明显的一个特征就是在百...

网站安全
14分钟前
1
0
JDK版本与major.minor version的对照关系

其实,只需要记住jdk6对于major.minor version 50即可,其他版本自行计算即可。 ---------------------

码代码的小司机
17分钟前
1
0
Gitlab安装

具体步骤如下: sudo yum install -y curl policycoreutils-python openssh-server cronie sudo lokkit -s http -s ssh sudo yum install postfix sudo service postfix start sudo chkconfi......

很好亦平凡ms
24分钟前
1
0
C++基础教程面向对象学习笔记及心得感悟[图]

C++基础教程面向对象学习笔记及心得感悟[图] 使用友元函数重载算术运算符: C ++中一些最常用的运算符是算术运算符 - 即加号运算符(+),减运算符( - ),乘法运算符(*)和除法运算符(/...

原创小博客
25分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部