I had a chance this weekend to start reading Jimmy Nilsson‘s new book, called Applying Domain-Driven Design and Patterns With Examples in C# and .NET. Currently I have read through Chapter 8.
Jimmy is touching on a lot of subjects in the book, which is no easy task. The main focus of the book is on the value of a domain model and the implementation of the domain layer using Domain-Driven Design. However, he is also touching on topics which are the subjects of many books, topics like: Test-Driven Development, Refactoring, OOP, and Design Patterns.
You don’t have to know or care about Test Driven Development or Refactoring to appreciate the book, but a good understanding of design patterns and OOP would be rather valuable. There are a lot of design patterns and object-oriented principles mentioned in the book.
- Design Patterns like Data Mapper, Identity Field, Identity Map, Lazy Load, Query Object, Repository, Unit of Work, etc.
- Object-Oriented Principles like Dependency-Inversion Principle and Single-Responsibility Principle.
Jimmy refers to Martin Fowler‘s Patterns of Enterprise Application Architecture ( POEAA ) quite a bit, so it would certainly be useful ( but not required ) to have on hand.
In Part I the book jumps around a lot to introduce a number of topics mentioned above and set the stage for the approach used in the book. Even Jimmy mentions this “jumping around” as well. There are a lot of little notes and tangents, but not enough to be distracting. This is almost unavoidable as this is a complicated subject and I can “sense” Jimmy wants to make sure he leaves nobody behind. Hence, a quick note or tangent to better clarify or define a subject is taken to help those who perhaps need it, but doesn’t distract those who are already familiar with the concept. Many of these notes and tangents are on various OOP and Design Patterns as well as topics that are very subjective and contextual in value.
In part II, Jimmy takes a domain model example and begins to build the domain layer using TDD. Jimmy’s style here is to discover the domain layer as if building one for the first time. You are essentially a fly on the wall of his brain, listening to his thoughts as he tries to cope with the building of the domain objects and when to introduce the infrastructure pieces of the domain layer ( factories and repositories ) using TDD. During this time he is also trying to 1) wrestle with how to avoid persistence, 2) discuss a number of design patterns in play, and 3) approach/handle the number of solutions and their tradeoffs that occur in every application.
My only concern this far ( Chapter 8 ) is that persistence has been reduced to “x.PersistAll()”. This is great in that we shouldn’t be distracted by it, but bad in that we know it is a dark cloud that hovers above our heads. Jimmy has also introduced this concept of a Workspace ( IWorkspace ) that is injected into the Repository and is a database abstraction layer that handles the unit of work ( transactions ), but we haven’t seen much of it. To be fair, however, Chapter 9 is entitled “Putting NHibernate into Action”, so I suspect and hope Jimmy will be letting us in on the necessary persistence portion of Domain-Driven Design
Thus far I give the book two thumbs up. In my opinion it is a must have companion to Domain-Driven Design by Eric Evans, because it offers up the missing ingredient – how to implement the domain model using C# and .NET. In my humble opinion it is also an easier read, as I remember being overwhelmed by Domain-Driven Design by Eric Evans when I first read it. Jimmy’s book has a real-world, pragmatic feel to it that doesn’t claim to be the end all answer and a solution without tradeoffs. He is providing us another tool in our toolbox, and I look forward to the rest of the book.
Some interesting community resources that may be of value as you work through the book:
- Domain-Driven Design.org
- Domain-Driven Design Yahoo Group
- Jimmy Nilsson’s Weblog
- NHibernate Best Practices with ASP.NET, Generics, and Unit Tests by Billy McCafferty
- OOP and Design Patterns Resources – Books Websites Articles