第二部分 模型驱动设计的构造块

    To keep a software implementation crisp and in lockstep with a model, in spite of messy realities, you must apply the best practices of modeling and design. This book is not an introduction to object-oriented design, nor does it propose radical design fundamentals. Domain-driven design shifts the emphasis of certain conventional ideas.

    为了保证软件实现得简洁并且与模型保持一致,不管实际情况如何复杂,必须运用建模和设计的最佳实践。本书既不是一本介绍面向对象设计的书,也不是为了提出一些基本的设计原理。领域驱动设计改变了某些传统观念的侧重点。

    Certain kinds of decisions keep the model and implementation aligned with each other, each reinforcing the other’s effectiveness. This alignment requires attention to the details of individual elements. Careful crafting at this small scale gives developers a steady platform from which to apply the modeling approaches of Parts III and IV.

    某些设计决策能够使模型和程序紧密结合在一起,互相促进对方的效用。这种结合要求我们注意每个元素的细节。对细节问题的精雕细琢能够打造出一个稳定的平台,开发人员可以在这个平台上运用第三部分和第四部分中要讲到的建模方法。

    The design style in this book largely follows the principle of “responsibility-driven design,” put forward in Wirfs-Brock et al. 1990 and updated in Wirfs-Brock 2003. It also draws heavily (especially in Part III) on the ideas of “design by contract” described in Meyer 1988. It is consistent with the general background of other widely held best practices of object-oriented design, which are described in such books as Larman 1998.

    当项目遇到或大或小的困难时,开发人员可能会发现这些原则都无法适用于项目当前的状况。为了使领域驱动设计过程更灵活,开发人员需要理解上面这些众所周知的基本原理是如何支持 MODEL-DRIVEN DESIGN 的,这样才能在设计过程中做出一些折中选择,而又不脱离正确的轨道。

    The material in the following three chapters is organized as a “pattern language” (see Appendix A), which will show how subtle model distinctions and design decisions affect the domain-driven design process.

    下面 3 章的内容是按照“模式语言”(参见附录 A)组织的,主要说明了细微的模型差别和设计决策是如何影响领域驱动设计过程的。

    The diagram on the top of the next page is a navigation map. It shows the patterns that will be presented in this section and a few of the ways they relate to each other.

    Sharing these standard patterns brings order to the design and makes it easier for team members to understand each other’s work. Using standard patterns also adds to the UBIQUITOUS LANGUAGE, which all team members can use to discuss model and design decisions.

    Developing a good domain model is an art. But the practical design and implementation of a model’s individual elements can be relatively systematic. Isolating the domain design from the mass of other concerns in the software system will greatly clarify the design’s connection to the model. Defining model elements according to certain distinctions sharpens their meanings. Following proven patterns for individual elements helps produce a model that is practical to implement.

    开发一个好的领域模型是一门艺术。而模型中各个元素的实际设计和实现则相对系统化。将领域设计与软件系统中的其他关注点分离会使设计与模型之间的关系非常清晰。根据不同的特征来定义模型元素则会使元素的意义更加鲜明。对每个元素使用已验证的模式有助于创建出更易于实现的模型。

    A navigation map of the language of MODEL-DRIVEN DESIGN

    Elaborate models can cut through complexity only if care is taken with the fundamentals, resulting in detailed elements that the team can confidently combine.