📜 ⬆️ ⬇️

Learning to design based on the domain (DDD: Domain Driven Design)

1. Introduction



In this article, I would like to talk about these three letters that are constantly on the ear, but for many who are a secret behind seven seals, as well as a number of resources that it would be nice to get acquainted with if you want to continue development in design based on the subject area DDD: Domain Driven Design).

2. So why DDD?



There are several domain implementation (Domain Logic) or Business Logic implementation patterns:
')
1) Table Module - is an object, in a single copy, that processes business logic for all records in a database table or view.

2) Transaction Script - organizes interaction with business logic through procedures that accept requests from the presentation layer.

3) Domain Model - directly, the object model of the domain, which includes both behavior and data.

These templates are described in more detail by Martin Fowler , in his book “The Architecture of Enterprise Software Applications. Enterprise Application Patterns ” (Patterns of Enterprise Application Architecture (P of EAA) ) . In this book, he shows that the first two patterns are more attractive at the beginning of work with the subject area, but also points out that as the complexity of the domain logic increases, it is worth paying more attention to supporting the infrastructure using the first two approaches, this time can be reduced if refer in his decision to the third of the above templates, the so-called “Domain Model”.

Based on this, we make a small conclusion that this template (“ Domain Model ”) is best suited, for example, for such a difficult area as the financial market. Most of the software created today is designed for various business needs, therefore some abstract, generalized solutions find their place in the market (with rather high competition) less and less. What am I writing about all this? Because DDD is not only high-quality design, but also an illustrative example of how to highlight the subject area in software, in order to more easily overcome difficulties, frequent changes, communication problems and other ailments of the subject area, instead of developing an ugly, difficult to understand system in which any change or correction is capable of bringing an avalanche of new and new defects on you.

DDD in no way denies the legacy of development practices, such as:



DDD only complements them. Finding the right model and abstractions in complex scenarios requires considerable knowledge in the field of object-oriented approach, and sufficient experience in applying various principles, patterns and practices, and not just DDD, as it may seem.

3. Where can I start?



If my “boring PR” design on the basis of the domain (DDD) has not tired you yet, then I think we should continue, if otherwise, then at least look at the links to the materials.

The first book that shed light on DDD for the general public was the so-called “Big Blue Book” (Memo. BBB: Big Blue Book): Domain-Driven Design: Tackling Complexity of the Heart of Software   by Eric Evans   (not yet translated into Russian).

The book is pleased in detail about what DDD is all about, and all related aspects, such as: domain language, patterns, design practices, refactoring, modeling, how to make development flexible, and much more. But even if you familiarize yourself with all the questions raised in the book (which is not quite an easy task), you will notice that questions are considered only from a theoretical point of view, leaving all the scope for practice (the book is not tied to a specific development platform). For most of us, reading pure theory, without reinforcement with practical examples, is not pleasant, so you can turn your attention to the abbreviated (and free to access) version of this book, prepared by the InfoQ : Domain Driven Design Quickly portal.

There are also some good presentations by Eric Evans from which to start:

1) DDD: putting the model to work

2) Eric Evans on DDD: Strategic Design

There are many other presentations, articles and interviews about DDD on the InfoQ portal.

So, with the theoretical part, we figured out where to find examples of practical application of DDD? An excellent book for this is .NET Domain-Driven Design with C #, Problem-Design-Solution written by Tim McCarthy.

In this book you will find practical examples:

1) How does the design and development process go, from defining requirements to writing code

2) How to organize architectural layers in their decisions

3) How to apply DDD patterns and practices

4) How to build a small frame for DDD

5) How to isolate the domain domain from the model

6) Modern patterns of data presentation and interaction with them (Model-View-ViewModel) in an environment like WPF (also applicable to Silverlight) in practice.

This book is an excellent DDD workshop containing a very wide range of ideas. The book begins with the development of requirements, and ends with the implementation of an industrial application, the source codes of which are available on Codeplex .

The whole concept of the book is built on 3 DDD pillars:

  1. PoEAA Martin Fowler
  2. DDD Erica Ivens
  3. Applying Domain - Driven Design and Patterns by Jimmy Nilsson's (“Applying Design Patterns: Problem-Oriented Application Design with Examples in C # and .NET” by Jimmy Nilsson)



In this book, all issues, techniques and patterns used in DDD are superficially examined, all examples are accompanied by code, which simplifies understanding. The book is excellent, but the Russian translation disappoint, so I recommend reading the original.





However, DDD is not just practical solutions or patterns, it is a thinking and approach, and there are a great many nuances to consider if you decide to follow DDD, such as: focusing on high priority is given to the model, developing the language of the subject area, the context of the model, process modeling, knowledge sharing, refactoring, strategic design, etc ... this is the main reason to get acquainted with the book by Eric Ivens, as it will give you a more comprehensive and deep understanding of the DDD philosophy.

DDD is not tied to a specific technology, however , it will not be so easy to comply with DDD without having good tools and practices in your arsenal, such as: TDD framework, ORM, the possibility of implementing Persistence Ignorance, IoC container (Inversion of Control ), and the capabilities of AOP (Aspect-Oriented Programming), of course, does not mean that we will need all these tools, but they will bring us closer to the implementation of DDD in practice. The practical value of these tools is that they allow you to isolate the domain model, which is the key objective of DDD. Jimmy Nilsson's book can introduce you to the capabilities and types of these tools. Jimmy also shows how to use enterprise application implementation patterns , and build, through them, a complete solution based on modern tools and practices.

Some implementations of DDD patterns on Ruby on Rails:

Some DDD (Domain Driven Design) Concepts implemented in Rails



4. Current issues DDD



DDDD: Distributed Domain Driven Design is also closely related to DDD. DDDD is DDD in distributed scripts. Currently, there are not many DDDD resources in a few words about DDDD: it covers the problem of message implementation and DDD, command and query separation ( Command Query Separation (CQS) ) helps to implement this approach. Greg Young reported that he is preparing a book on DDDD .

SOA and DDD are another voluminous topic often discussed by Udi Dahan.

5. DDD patterns, concepts and concepts



In industrial applications, DDD uses a number of templates, some of which are described in the book by Eric Evens, but this does not negate the use of an object-oriented approach, including GoF templates , Martin Fowler templates described in his PoEAA , Enterprise Application Integration Templates , etc. ...

Here are some of them:



6. Application examples



Finding good examples of implementing DDD is very difficult, not because they do not exist, but because the real power of DDD is realized in applications that are used in fairly complex areas and, as a rule, are commercial projects. However, you can find some pretty good projects where you can trace some ideas about the implementation of DDD patterns.

Here they are:

1) The application of Tim McCarthy his project , described in detail in his book. He describes not only the use of patterns, but also emphasizes the development of a domain model from the point of view of DDD.

The project is also interesting because it is built on .NET 3.5 and demonstrates all the power of the modern approach of binding data to the domain model (data binding, implementation of the MVVM pattern). His style is also notable for the ability to allocate abstractions and reusable code.

2) The next project to which you should pay attention is the application developed by Yves Goeleven , the creation of this application is described in his blog (also devoted to the basic concepts of DDD). Its other application is the DDD framework . Attention should be paid to its implementation of the interaction of the Repository and Specification templates.

3) Billy McCafferty develops a stunning open source framework focused on DDD, called S # arp Architecture . It has a very good description , which includes the description of templates and approaches contained in the framework. The framework aims to develop ASP.NET MVC applications using NHibernate.

4) The C # Domain-Driven Design sample application (ndddsample) , this application, developed by Jimmy Nilsson, demonstrates breaking the application into key layers in terms of DDD. It also demonstrates the practical use of building block patterns in the subject area of ​​cargo transportation, described in his book.

This project is based on the joint work of Erik Ivens “Domain Language” and the Swedish consulting company “Citerus”.

The purpose of this project:



here is more detailed information .

7. Domain Driven Design Resources



Official site - http://domaindrivendesign.org/

Discussion group - http://tech.groups.yahoo.com/group/domaindrivendesign/ is an adult group, a very good source of ideas, a place to discuss all kinds of problems in the area of ​​DDD. Experienced people at DDD can answer your questions in it, even Eric Ivens :-).

Jimmy Bogard's blog - http://www.lostechies.com/blogs/jimmy_bogard/default.aspx

Colin Jack's blog - http://colinjack.blogspot.com/

Greg Young's blog - http://codebetter.com/blogs/gregyoung/default.aspx

Casey Charlton's blog - http://devlicio.us/blogs/casey/

Udi Dahan's blog - http://www.udidahan.com/

Introduction to Domain-Driven Design - http://msdn.microsoft.com/ru-ru/magazine/dd419654.aspx


8. Conclusion



If you are interested in expanding your “object-oriented horizons” in complex corporate systems and exploring new ways of developing and designing, then DDD is exactly what you need.

http://weblogs.asp.net/arturtrosin/archive/2009/02/09/domain-driven-design-learning.aspx

Source: https://habr.com/ru/post/61524/


All Articles