什么是领域驱动设计?

发布于 2024-10-22 23:48:47 字数 116 浏览 2 评论 0原文

有人可以(用简洁的术语)解释一下领域驱动设计到底是什么吗?我经常看到这个术语,但真的不明白它是什么或它是什么样子。它与非领域驱动设计有何不同?

另外,有人可以解释什么是领域对象吗?域与普通对象有何不同?

Can somebody please explain (in succinct terms) what exactly is domain driven design? I see the term quite a lot but really don't understand what it is or what it looks like. How does it differ from non-domain driven design?

Also, can somebody explain what a Domain Object is? How does domain differ from normal objects?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

漫雪独思 2024-10-29 23:48:48

编辑:

由于这似乎是 Google 上的最佳结果,而我下面的答案不是,请参考这个更好的答案:

https:/ /stackoverflow.com/a/1222488/1240557

旧答案(不太完整:))

为了创建好的软件,您必须知道该软件是什么
就是这样。您无法创建银行软件系统,除非您
必须充分了解银行业务的全部内容
了解银行领域。

来自:Eric Evans 的领域驱动设计。

这本书很好地描述了 DDD。

注册以下载本书的摘要。

EDIT:

As this seem to be a top result on Google and my answer below is not, please refer to this much better answer:

https://stackoverflow.com/a/1222488/1240557

OLD ANSWER (not so complete :))

In order to create good software, you have to know what that software
is all about. You cannot create a banking software system unless you
have a good understanding of what banking is all about, one must
understand the domain of banking.

From: Domain Driven Design by Eric Evans.

This book does a pretty good job of describing DDD.

Register to download a summary of the book.

灯角 2024-10-29 23:48:48

领域驱动设计是一种用于开发复杂系统的方法和流程规定,其重点是将问题域中的活动、任务、事件和数据映射到解决方案域的技术工件。

领域驱动设计的重点是理解问题域,以便创建问题域的抽象模型,然后可以在一组特定的技术中实现该模型。领域驱动设计作为一种方法论,为模型开发和技术开发如何产生一个既能满足使用人员的需求,又能在面对问题领域的变化时保持稳健的系统提供了指导。

领域驱动设计的流程方面涉及领域专家(了解问题领域的人员)和设计/架构专家(了解解决方案领域的人员)之间的协作。这个想法是建立一个具有共享语言的共享模型,以便当来自这两个不同领域的人们以两种不同的视角讨论解决方案时,他们实际上是在讨论具有共享概念的共享知识库。

需要特定系统的人员与设计和实施该系统的人员之间缺乏共同的问题领域理解似乎是项目成功的核心障碍。领域驱动设计是解决这一障碍的一种方法。

它不仅仅是拥有一个对象模型。重点实际上是共享沟通和改进协作,以便可以发现问题领域内的实际需求,并创建适当的解决方案来满足这些需求。

领域驱动设计:好的和具有挑战性的通过以下评论提供了简要概述:

DDD 有助于发现顶层架构并告知
软件需要的领域的力学和动力学
复制。具体来说,这意味着出色的 DDD 分析
最大限度地减少领域专家和软件之间的误解
架构师,它减少了后续昂贵请求的数量
为了改变。通过将域复杂性分解为较小的上下文,
DDD 避免强迫项目架构师设计臃肿的对象
模型,这是在锻炼中浪费大量时间的地方
实施细节——部分原因是实体数量
处理的内容通常会超出会议室白板的大小。

另请参阅这篇文章服务架构的领域驱动设计,其中提供了一个简短的例子。本文提供了领域驱动设计的以下缩略图描述。

领域驱动设计提倡基于实际的建模
与我们的用例相关的业务。由于现在年纪越来越大并且
炒作程度降低,我们中的许多人忘记了 DDD 方法确实
有助于理解手头的问题并设计软件
对解决方案的共同理解。在构建应用程序时,
DDD 将问题视为域和子域。它描述了
将问题的独立步骤/区域作为有界上下文,强调
通用语言来谈论这些问题,并添加了许多技术
概念,如实体、值对象和聚合根规则
支持实施。

Martin Fowler 撰写了许多文章,其中提到了领域驱动设计作为一种方法。例如,本文 BoundedContext 概述了领域驱动开发中的有界上下文概念。

在那些年轻的日子里,我们被建议建立一个统一的模型
整个业务,但 DDD 认识到我们已经了解到“总
大型系统的领域模型的统一不会
可行或具有成本效益”1 因此 DDD 划分了一个大的部分。
将系统划分为限界上下文,每个限界上下文都可以有一个统一的模型 -
本质上是构建 MultipleCanonicalModel 的一种方法。

Domain Driven Design is a methodology and process prescription for the development of complex systems whose focus is mapping activities, tasks, events, and data within a problem domain into the technology artifacts of a solution domain.

The emphasis of Domain Driven Design is to understand the problem domain in order to create an abstract model of the problem domain which can then be implemented in a particular set of technologies. Domain Driven Design as a methodology provides guidelines for how this model development and technology development can result in a system that meets the needs of the people using it while also being robust in the face of change in the problem domain.

The process side of Domain Driven Design involves the collaboration between domain experts, people who know the problem domain, and the design/architecture experts, people who know the solution domain. The idea is to have a shared model with shared language so that as people from these two different domains with their two different perspectives discuss the solution they are actually discussing a shared knowledge base with shared concepts.

The lack of a shared problem domain understanding between the people who need a particular system and the people who are designing and implementing the system seems to be a core impediment to successful projects. Domain Driven Design is a methodology to address this impediment.

It is more than having an object model. The focus is really about the shared communication and improving collaboration so that the actual needs within the problem domain can be discovered and an appropriate solution created to meet those needs.

Domain-Driven Design: The Good and The Challenging provides a brief overview with this comment:

DDD helps discover the top-level architecture and inform about the
mechanics and dynamics of the domain that the software needs to
replicate. Concretely, it means that a well done DDD analysis
minimizes misunderstandings between domain experts and software
architects, and it reduces the subsequent number of expensive requests
for change. By splitting the domain complexity in smaller contexts,
DDD avoids forcing project architects to design a bloated object
model, which is where a lot of time is lost in working out
implementation details — in part because the number of entities to
deal with often grows beyond the size of conference-room white boards.

Also see this article Domain Driven Design for Services Architecture which provides a short example. The article provides the following thumbnail description of Domain Driven Design.

Domain Driven Design advocates modeling based on the reality of
business as relevant to our use cases. As it is now getting older and
hype level decreasing, many of us forget that the DDD approach really
helps in understanding the problem at hand and design software towards
the common understanding of the solution. When building applications,
DDD talks about problems as domains and subdomains. It describes
independent steps/areas of problems as bounded contexts, emphasizes a
common language to talk about these problems, and adds many technical
concepts, like entities, value objects and aggregate root rules to
support the implementation.

Martin Fowler has written a number of articles in which Domain Driven Design as a methodology is mentioned. For instance this article, BoundedContext, provides an overview of the bounded context concept from Domain Driven Development.

In those younger days we were advised to build a unified model of the
entire business, but DDD recognizes that we've learned that "total
unification of the domain model for a large system will not be
feasible or cost-effective" 1. So instead DDD divides up a large
system into Bounded Contexts, each of which can have a unified model -
essentially a way of structuring MultipleCanonicalModels.

心凉 2024-10-29 23:48:48

只能通过首先理解以下内容来理解领域驱动设计:

什么是域名?

为其构建系统的领域。机场管理、保险销售、咖啡店、轨道飞行,应有尽有。

应用程序跨越多个不同的域并不罕见。例如,在线零售系统可能在运输(根据商品和目的地选择适当的交付方式)、定价(包括促销和按位置等进行特定于用户的定价)和推荐(计算相关按购买历史记录的产品)。

什么是模型?

“对当前问题的有用近似。” ——格里·萨斯曼

Employee 类并不是真正的雇员。它模拟了一个真实的员工。我们知道该模型并不能捕获真实员工的所有信息,但这不是重点。它只是为了捕获我们对当前上下文感兴趣的内容。

不同的领域可能对对同一事物进行建模的不同方式感兴趣。例如,薪资部门和人力资源部门可能会以不同的方式对员工进行建模。

什么是领域模型?

域模型。

什么是领域驱动设计 (DDD)?

这是一种深深重视领域模型并将其与实现联系起来的开发方法。 DDD 是由 Eric Evans 创造并最初开发的。

摘自此处

You CAN ONLY understand Domain driven design by first comprehending what the following are:

What is a domain?

The field for which a system is built. Airport management, insurance sales, coffee shops, orbital flight, you name it.

It's not unusual for an application to span several different domains. For example, an online retail system might be working in the domains of shipping (picking appropriate ways to deliver, depending on items and destination), pricing (including promotions and user-specific pricing by, say, location), and recommendations (calculating related products by purchase history).

What is a model?

"A useful approximation to the problem at hand." -- Gerry Sussman

An Employee class is not a real employee. It models a real employee. We know that the model does not capture everything about real employees, and that's not the point of it. It's only meant to capture what we are interested in for the current context.

Different domains may be interested in different ways to model the same thing. For example, the salary department and the human resources department may model employees in different ways.

What is a domain model?

A model for a domain.

What is Domain-Driven Design (DDD)?

It is a development approach that deeply values the domain model and connects it to the implementation. DDD was coined and initially developed by Eric Evans.

Culled from here

归属感 2024-10-29 23:48:48

这是另一篇关于领域驱动设计的好文章。如果您的申请比大学作业更严肃。基本前提是围绕实体构建一切并拥有强大的领域模型。区分提供与基础设施相关的服务(例如发送电子邮件、持久数据)的服务和实际执行核心业务需求的服务。

希望有帮助。

Here is another good article that you may check out on Domain Driven Design. if your application is anything serious than college assignment. The basic premise is structure everything around your entities and have a strong domain model. Differentiate between services that provide infrastructure related things (like sending email, persisting data) and services that actually do things that are your core business requirments.

Hope that helps.

逆光下的微笑 2024-10-29 23:48:48

正如在 TDD 和 TDD 中一样。 BDD 您/团队最关注的是系统的测试和行为,而不是代码实现。

类似地,当系统分析师、产品负责人、开发团队,当然还有代码(实体/类、变量、函数、用户界面流程)使用相同的语言进行通信时,其称为领域驱动设计

DDD 是一个思维过程。在对软件设计进行建模时,您需要将业务领域/流程放在关注的中心,而不是数据结构、数据流、技术、内部和外部依赖性。

有很多方法可以使用 DDD

  • 事件源(使用事件作为单一事实来源)、
  • 关系数据库、
  • 图形数据库
  • 使用函数语言的

来建模系统。领域对象:

对象

  • 用非常天真的话说,一个基于业务流程/流程命名的
  • 拥有完全的控制权。在其内部状态 ie 公开操作状态的方法。
  • 始终满足其使用上下文中的所有业务不变量/业务规则。
  • 遵循单一职责原则

As in TDD & BDD you/ team focus the most on test and behavior of the system than code implementation.

Similar way when system analyst, product owner, development team and ofcourse the code - entities/ classes, variables, functions, user interfaces processes communicate using the same language, its called Domain Driven Design

DDD is a thought process. When modeling a design of software you need to keep business domain/process in the center of attention rather than data structures, data flows, technology, internal and external dependencies.

There are many approaches to model systerm using DDD

  • event sourcing (using events as a single source of truth)
  • relational databases
  • graph databases
  • using functional languages

Domain object:

In very naive words, an object which

  • has name based on business process/flow
  • has complete control on its internal state i.e exposes methods to manipulate state.
  • always fulfill all business invariants/business rules in context of its use.
  • follows single responsibility principle
童话里做英雄 2024-10-29 23:48:48

DDD(领域驱动设计)是一个有用的概念,用于分析项目的需求并处理这些需求的复杂性。在此之前,人们通过考虑类和表之间的关系来分析这些需求,实际上他们的设计是基于数据库表的它并不古老,但有一些问题:

  • 在具有复杂需求的大型项目中,它没有用,尽管这是小型项目的一种很好的设计方式。

  • 当你与非技术人员打交道时,他们没有技术概念,这种冲突可能会给我们的项目带来一些巨大的问题。

因此,DDD 处理第一个问题时,将主项目视为一个域,并将该项目的每个部分分割成我们著名的限界上下文的小块,并且每个块对其他块没有任何影响。
第二个问题已经通过通用语言解决了,这是技术团队成员和产品所有者之间的通用语言,这些产品所有者不是技术人员,但对他们的需求有足够的了解。

通常,的简单定义是主要的为业主和其他团队赚钱的项目。

DDD(domain driven design) is a useful concept for analyse of requirements of a project and handling the complexity of these requirements.Before that people were analysing these requirements with considering the relationships between classes and tables and in fact their design were based on database tables relationships it is not old but it has some problems:

  • In big projects with complex requirements it is not useful although this is a great way of design for small projects.

  • when you are dealing with none technical persons that they don,t have technical concept, this conflict may cause some huge problems in our project.

So DDD handle the first problem with considering the main project as a Domain and splitting each part of this project to small pieces which we are famous to Bounded Context and each of them do not have any influence on other pieces.
And the second problem has been solved with a ubiquitous language which is a common language between technical team members and Product owners which are not technical but have enough knowledge about their requirements

Generally the simple definition for Domain is the main project that makes money for the owners and other teams.

凉城凉梦凉人心 2024-10-29 23:48:48

我不想重复别人的答案,所以,简而言之,我解释一些常见的误解

  • 实用资源:领域驱动设计的模式、原则和实践,作者:Scott Millett
  • 这是复杂业务系统的一种方法论。与业务专家沟通时,它消除了所有技术问题
  • 。它为整个开发团队提供了对业务(简化和提炼的模型)的广泛理解。
  • 它通过使用通用语言(整个开发团队、业务专家、业务分析师等都能理解的语言)使业务模型与代码模型保持同步,该语言用于开发团队内部的沟通或与其他团队一起开发
  • 与项目管理无关。虽然它可以完美地运用在像敏捷这样的项目管理方法中。
  • 您应该避免在整个项目中使用它

    <块引用>

    DDD 强调需要将大部分精力集中在核心子域上。核心子域是
    产品的成功与失败的区别。它是
    产品的独特卖点,也是制造而不是购买的原因。

    基本上是因为花费了太多的时间和精力。因此,建议将整个域分解为子域,并将其应用于具有高商业价值的子域。 (例如不在电子邮件等通用子域中,...)

  • 它不是面向对象的编程。它主要是解决问题的方法并且(有时)你不需要使用OO模式(例如四人帮)在您的领域模型中。仅仅是因为业务专家无法理解它(他们对工厂、装饰器不太了解……)。 DDD 中甚至有一些模式(例如事务脚本、表模块)并不是 100% 符合 OO 概念。

I do not want to repeat others' answers, so, in short I explain some common misunderstanding

  • Practical resource: PATTERNS, PRINCIPLES, AND PRACTICES OF DOMAIN-DRIVEN DESIGN by Scott Millett
  • It is a methodology for complicated business systems. It takes all the technical matters out when communicating with business experts
  • It provides an extensive understanding of (simplified and distilled model of) business across the whole dev team.
  • it keeps business model in sync with code model by using ubiquitous language (the language understood by the whole dev team, business experts, business analysts, ...), which is used for communication within the dev team or dev with other teams
  • It has nothing to do with Project Management. Although it can be perfectly used in project management methods like Agile.
  • You should avoid using it all across your project

    DDD stresses the need to focus the most effort on the core subdomain. The core subdomain is the
    area of your product that will be the difference between it being a success and it being a failure. It’s
    the product’s unique selling point, the reason it is being built rather than bought.

    Basically, it is because it takes too much time and effort. So, it is suggested to break down the whole domain into subdomain and just apply it in those with high business value. (ex not in generic subdomain like email, ...)

  • It is not object oriented programming. It is mostly problem solving approach and (sometimes) you do not need to use OO patterns (such as Gang of Four) in your domain models. Simply because it can not be understood by Business Experts (they do not know much about Factory, Decorator, ...). There are even some patterns in DDD (such as The Transaction Script, Table Module) which are not 100% in line with OO concepts.

动次打次papapa 2024-10-29 23:48:48

我相信下面的 pdf 将为您提供更全面的了解。 Eric Evans 的领域驱动设计

注意:想想一个您可以从事的项目,应用您所理解的小事情并查看最佳实践。它还将帮助您提高微服务架构设计方法的能力。

I believe the following pdf will give you the bigger picture. Domain Driven Design by Eric Evans

NOTE: Think of a project you can work on, apply the little things you understood and see best practices. It will help you to grow your ability to the micro service architecture design approach too.

静赏你的温柔 2024-10-29 23:48:48

通过以下方式获得组织对问题领域的广泛理解
为每个子问题域开发一种通用语言(通用心理模型)。
在解决方案域(代码)中尽可能接近地使用该语言。
然后才选择技术。
不要受技术驱动,而要受问题领域或业务驱动。

Get an organization wide understanding of the problem domain by
developing a ubiquitous language (a common mental model) per sub-problem-domain.
Use that language as close as possible in solution domains (code).
Only then choose technologies.
Don't be technology driven but problem domain or business driven.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文