用Service充当Domain Object

今天看到后端一个ReportService里面的代码太过于复杂,所以想把逻辑放到Report这个DTO里面,作为DO,也就想到了充血模型。

目前工程的依赖关系:

controller -> service -> dao -> domain

我试着重构一下,啊,工程太过于浩大,因为目前我们把EntityBean也叫成domain,搞得我把DO放到domain里面,结果引用不到service和dao,那还怎么保存Report呢。

所以,我想到一个办法,就是在增加一个DomainObject 层,把之前的domain改成entitybean,新的依赖关系:

controller -> service -> domain object -> dao -> entity bean

但这样一看,ReportService其实就相当于Report的domain object,名字不同,其实就是。

原文地址:https://www.cnblogs.com/evanxyhu/p/service-as-domain-object.html