Learning to Design Based on a Domain (DDD: Domain Driven Design)

    1. Introduction



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

    2. So why DDD?



    There are several templates for the implementation of a domain (Domain Logic) or Business Logic (Business Logic):

    1) Table Module - is an object in a single instance 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 level.

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

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

    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. Why am I writing about all this? Because DDD is not only high-quality design, but also a good example of how to highlight a 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 can bring down on you an avalanche of ever new defects.

    DDD does not in any way deny a legacy of development practices such as:



    DDD only complements them. Finding a suitable model and abstractions in complex scenarios requires considerable knowledge in the field of an 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” domain-based design (DDD) has not yet bored you, then I think we should continue, if not, look at least the links to the materials.

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

    The book is pleased to talk in detail about what DDD is, and all related aspects, such as: domain language, templates, design practices, refactoring, modeling, how to make development flexibleand much more. But even if you familiarize yourself with all the issues raised in the book (which is not an easy task), you will notice that the 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, we don’t like reading a pure theory, without practical examples, in this connection we can turn our attention to an abridged (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 to get you started:

    1) DDD: putting the model to work

    2)Eric Evans on DDD: Strategic Design

    The InfoQ portal has many other DDD presentations, articles, and interviews .

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

    In this book you will find practical examples:

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

    2) How to organize architectural layers in your decisions

    3) How to apply DDD templates and practices

    4) How to build a small framework for DDD

    5) How to isolate the domain of the subject domain from the model

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

    This book is an excellent DDD workshop with 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 code of which is available on Codeplex .

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

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



    This book superficially addresses all the issues, techniques and patterns used in DDD, all examples are accompanied by code, which simplifies understanding. The book is excellent, but the Russian translation let us down, therefore, 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 that must be considered if you decide to follow DDD, such as: focusing on high priority given to the model, developing the domain language, the context of the model, the modeling process, sharing knowledge, refactoring, strategic design, etc ... this is the main reason to read Eric Evens book, as it will give you a more voluminous and deeper understanding of the DDD philosophy.

    DDDs are not technology specific,however, observing DDD will not be easy without the good tools and practices in your arsenal, such as: TDD framework, ORM, the ability to implement Persistence Ignorance, IoC container (Inversion of Control), and AOP capabilities (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 goal 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, thanks to them, an integral solution based on modern tools and practices.

    Some implementations of DDD templates on Ruby On Rails:

    Some DDD (Domain Driven Design) Concepts implemented in Rails



    4. Topical issues of DDD



    C DDD is also closely related to a topic such as DDDD: Distributed Domain Driven Design. DDDD is DDD in distributed scripts. Currently, there are not many DDDD resources in a few words about DDDD: it covers the issue of message and DDD implementation, Command Query Separation (CQS ) helps to implement this approach. Greg Young ( by Greg Young ) said that he was preparing a book on DDDD .

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

    5. DDD templates, 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 the object-oriented approach, including GoF templatesMartin Fowler's templates described in his PoEAA , Enterprise Application Integration Templates , etc. ...

    Here are some of them:



    6. Application Examples



    It is very difficult to find good examples of DDD implementation, not because they do not exist, but because the real power of DDD is realized in applications used in rather complex areas, and, as a rule, which are commercial projects. However, you can find some good projects in which you can trace some ideas for implementing DDD templates.

    Here they are:

    1) Tim McCarthy’s app is his project , described in detail in his book. He describes not only the use of templates, but also focuses on the development of a domain model from the point of view of DDD.

    The project is also interesting in that it is built on .NET 3.5 and demonstrates the full power of the modern data binding model with the domain model (data binding, implementation of the MVVM template). His style is also remarkable for his ability to distinguish 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). His other application is a DDD framework . You should pay attention to its implementation of the interaction of the Repository and Specification templates . 

    3) Billy McCafferty is developing an amazing open source DDD-focused framework called S # arp Architecture . He has a very good description , including a description of the templates and approaches enclosed in the framework. The framework aims to develop ASP.NET MVC applications using NHibernate.

    4) The C # Domain-Driven Design sample application (ndddsample) , an application developed by Jimmy Nilsson, demonstrates how the application is split into key layers in terms of DDD. The practical application of building block templates in the subject area of ​​cargo transportation described in his book is also demonstrated .

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

    The purpose of this project:

    • Show the practical use of using DDD with .NET.
    • The use of current utilities, technologies and development methodologies in the field of .NET, discussed by ALT.NET community .
    • Give practical examples of the implementation of typical DDD applications.
    • Show the way to implement DDD on a specific platform, which will allow you to easily do the same on any other platform.
    • Help in choosing practicable practices. Different approaches will allow the community to discuss them and choose the appropriate one for a particular implementation.


    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 for discussions of all kinds of problems in the field of DDD. In it, people experienced in DDD can answer your questions, 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/en-us/magazine/dd419654.aspx


    8. Conclusion



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

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

    Also popular now: