Last year I finished reading the excellent book Domain-driven Design, by Eric Evans; but it was not until now that I’ve managed to put aside some time to write about it.
In a time when we have lots of different kinds of cool tools and technologies, it can be easy for us developers to become entangled in those issues and forget to pay close attention to the core problem domain. The approach of Domain-driven Design (DDD) shifts the focus back to the domain, joining together developers, users and domain experts through the use of a common language, spoken and understood by everyone: the ubiquitous language. With the terms of this shared language, we can develop a model which will be used to drive design (hence the term “model-driven design“). The idea is for the code to faithfully reflect this model. This approach enables excellent communication among the stakeholders and empowers the design with the richness of the domain which in turn makes it possible for the system to evolve more easily as the users demand new features.
And that’s Domain-driven Design in a nutshell! Simple, isn’t it?
Yes, that is DDD. However, putting that into practice is a whole different thing. In the book, Eric Evans explains how to apply DDD, what are the some of the challenges and difficulties, how to express the model in code, supple design, patterns, large-scale structures, etc. I definitely recommend reading the book, especially parts I, II and III.
Just one more comment to finish this post: I came to the conclusion that it is virtually impossible to apply DDD without continuous Refactoring. This happens because the ubiquitous language and the model are constantly evolving as developers and users gain new insights. Actually, coming up with a good model is a strenuous task and, therefore, things are likely to change often (especially at the beginning of the project) and the code needs to easily accomodate these changes. Since it’s unwise to do refactoring without automated tests, some flavor of Test-driven Development is highly desirable as well.