Are Repositories Domain Model Objects?

发布于 2014/10/12 11:40
字数 392
阅读 10
收藏 0
点赞 0
评论 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
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


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

红薯 ⋅ 2014/03/04 ⋅ 0

centos5.6 gitolite-admin 问题,求助

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

橙汁儿 ⋅ 2012/01/06 ⋅ 0

领域驱动设计(DDD)框架--Synopse mORMot framework

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

炽火 ⋅ 2013/12/03 ⋅ 3


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

CakePHP 3.1.8 发布,PHP 开发框架

CakePHP 3.1.8 发布,此版本的更新内容如下: Bug修复: Using on a BelongsToMany association with conditions no longer emits invalid SQL. (@markstory) Generated reciprocal BelongsT......

oschina ⋅ 2016/01/25 ⋅ 6

[转]Design Rules for Model-View-Presenter

原文地址:http://kjellsj.blogspot.com/2008/05/design-rules-for-model-view-presenter.html In my current project the MVP pattern is used in the supervising controller mode. The MV......

长平狐 ⋅ 2012/09/04 ⋅ 0

Creating a REST API with Spring Boot and MongoDB

Spring Boot is an opinionated framework that simplifies the development of Spring applications. It frees us from the slavery of complex configuration files and helps us to creat......

perfectspr ⋅ 2014/12/11 ⋅ 0

SCIM: System for Cross-domain Identity Management

官网:http://www.simplecloud.info/ Overview The System for Cross-domain Identity Management (SCIM) specification is designed to make managing user identities in cloud-based appl......

Sam_Li ⋅ 2014/04/02 ⋅ 0


XenAPI方式: #!/usr/bin/python from xen.xm.XenAPI import Session session=Session('httpu:///var/run/xend/xen-api.sock') try: session.loginwithpassword('', '') xenapi=session.xena......

文艺小青年 ⋅ 2017/05/11 ⋅ 0






因为阿里云现在服务器已经停用了,所以上面的配置已经失效。 服务端开源地址:https://gitee.com/goalya/chat4.git 客户端开源地址:https://gitee.com/goalya/client4.git 具体运行界面请参考...

算法之名 ⋅ 36分钟前 ⋅ 0


装饰者模式 定义 动态地给一个对象添加一些额外的职责。就增加功能来说,装饰模式相比生成子类更为灵活。 通用类图 意图 动态地给一个对象添加一些额外的职责。就增加功能来说,装饰模式相比...

gaob2001 ⋅ 今天 ⋅ 0


JavaScript零基础入门——(八)JavaScript的数组 欢迎大家回到我们的JavaScript零基础入门,上一节课我们讲了有关JavaScript正则表达式的相关知识点,便于大家更好的对字符串进行处理。这一...

JandenMa ⋅ 今天 ⋅ 0


转自:http://dblab.xmu.edu.cn/blog/maven-network-problem/ cd ~/.sbt/launchers/0.13.9unzip -q ./sbt-launch.jar 修改 vi sbt/sbt.boot.properties 增加一个oschina库地址: [reposit......

狐狸老侠 ⋅ 今天 ⋅ 0


我们看到越来越多的数据泄漏事故、勒索软件和其他类型的网络攻击,这使得安全成为一个热门话题。 去年,企业IT面临的威胁仍然处于非常高的水平,每天都会看到媒体报道大量数据泄漏事故和攻击...

p柯西 ⋅ 今天 ⋅ 0


前提 安装jdk 下载 wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.7.6/hadoop-2.7.6.tar.gz 解压 配置 vim /etc/profile # 配置java环境变量 export JAVA_HOME=/opt/jdk1......

晨猫 ⋅ 今天 ⋅ 0


crontab crontab 是一个用于设置周期性被执行的任务工具。 周期性执行的任务列表称为Cron Table crontab(选项)(参数) -e:编辑该用户的计时器设置; -l:列出该用户的计时器设置; -r:删除该...

Linux学习笔记 ⋅ 今天 ⋅ 0


5. final域的内存语义 5.1 final域的重排序规则 1.对于final域,编译器和处理器要遵守两个重排序规则: (1)在构造函数内对一个final域的写入,与随后把这个被构造对象的引用赋值给一个引用...

江左煤郎 ⋅ 今天 ⋅ 0


面试-正向代理和反向代理 Nginx 是一个高性能的反向代理服务器,但同时也支持正向代理方式的配置。

秋日芒草 ⋅ 今天 ⋅ 0

Spring 依赖注入(DI)

1、Setter方法注入: 通过设置方法注入依赖。这种方法既简单又常用。 类中定义set()方法: public class HelloWorldOutput{ HelloWorld helloWorld; public void setHelloWorld...

霍淇滨 ⋅ 昨天 ⋅ 0