What are domain objects and domain services in software architecture? I am not familiar with them or how they differ from the business logic layer?

什么是软件架构中的域对象和域服务?我不熟悉它们或它们与业务逻辑层的区别?

4 个解决方案

#1


75

Different people use these terms in somewhat different ways, but here's my take:

不同的人以不同的方式使用这些术语,但这是我的看法:

1) "Business" and "domain" are roughly synonyms. "Domain" is a bit more general in that it doesn't make the assumption that you're writing a business application. So if we were writing a scientific app or a game, we might prefer to refer to the relevant part of the code as "domain" code rather than "business" code. So in the remainder of this explanation I'll use "domain" since it's more general.

1)“业务”和“域”大致是同义词。 “域”更为通用,因为它不会假设您正在编写业务应用程序。因此,如果我们正在编写科学应用程序或游戏,我们可能更愿意将代码的相关部分称为“域”代码而不是“业务”代码。因此,在本解释的其余部分中,我将使用“域”,因为它更通用。

2) "Domain logic" comprehends both "domain objects" and "domain services". For various reasons (technical and otherwise) many architectures employ a design where the domain logic is divided into objects for storing data ("domain objects") and objects that manipulate those ("domain services"). Martin Fowler and others have pointed out that that's not very OO since a big part of the OO concept is to put functionality together with data, and that's right, but it is what it is. Domain objects are the data and domain services are the do-stuff-with-the-data part.

2)“域逻辑”包括“域对象”和“域服务”。由于各种原因(技术上和其他原因),许多体系结构采用一种设计,其中域逻辑被分成用于存储数据的对象(“域对象”)和操纵那些的对象(“域服务”)。 Martin Fowler和其他人指出,由于OO概念的很大一部分是将功能与数据结合在一起,所以这并不是非常OO,这是正确的,但事实就是如此。域对象是数据,域服务是与数据一起做的事情。

3) In domain-driven design, the idea is to get back to true OO design, and so the various service methods make their way back to the domain objects so that you have objects in the OO sense rather than what are sometimes called "anemic" objects. In a DDD the domain objects themselves are more robust and so they form the domain logic. In reality there may still be some domain services too, but this is typically smaller in a DDD than in a more traditional domain objects vs. services model.

3)在域驱动设计中,想法是回到真正的OO设计,因此各种服务方法回到域对象,以便你有OO意义上的对象而不是有时被称为“贫血”的对象“对象。在DDD中,域对象本身更健壮,因此它们形成域逻辑。实际上可能仍然存在一些域服务,但是DDD中的这种服务通常比更传统的域对象与服务模型中的更小。

更多相关文章

  1. 如何从Java中的类名获取类对象
  2. Java面向对象三大特性
  3. 请问java中调用一个静态方法()内传入一个对象是表示什么意思?
  4. Java记录 -88- 利用反射机制调用对象的私有方法和属性
  5. Java开发水吧点饮品系统(顶层父类对象做接口参数)
  6. 如何知道Object是否为String类型对象?
  7. java入门第三篇-面向对象;
  8. 如何将树路径转换为json对象
  9. OOP面向对象编程(一)-------方法的重载

随机推荐

  1. 基于geopandas的空间数据分析—geoplot篇
  2. geopandas&geoplot近期重要更新
  3. 20 行代码:Serverless 架构下用 Python 轻
  4. 成天说要删库跑路,这次真的有人干了
  5. Python+Kepler.gl轻松制作时间轮播地图
  6. 必知必会的8个Python列表技巧
  7. JavaScript的工作原理:V8引擎内部机制及优
  8. 对比Excel,学习pandas数据透视表
  9. 数据分析实战:利用python对心脏病数据集进
  10. 机器学习中最常见的四种分类模型