DDD Community Essay: Effective Aggregate Design

My essay on Effective Aggregate Design was released late on October 2. In just two days there have been nearly 500 views/downloads. This is clear indication of the challenges faced by many when designing aggregates using the DDD tactical pattern.

Here’s a brief overview of the three-part series:

Part I considers the modeling of an aggregate.

Part II will look at the model and design issues of how different aggregates relate to each other (available in November).

Part III will discuss the discovery process: how to recognize when a design problem is a hint of a new insight, and how different aggregate models are tried and then superseded (available in December).

Part I has already received very positive reviews by the DDD community, such as this tweet:

weakreference: Great essay on aggregates and aggregate modeling by @VaughnVernon http://t.co/IXmiOTkw Looking forward to part 2!

Comments

  1. Hi Vaughn,

    Great stuff in those articles! A real help.

    I’ve been thinking about the “modify only one aggregate per transaction” rule (of thumb) a little bit and have trouble applying this to cases where there are clearly 2 ARs involved in getting a particular business objective done. I guess a typical example would be doing a bank transfer.

    In this case, there is a clear invariant that the sum of the money in the accounts before and after the transfer are the same. I would argue that eventual consistency is not sufficient here, so if you model an account as AR you need to modify them both in the same transaction. But this violates the rule of thumb. I guess you could also take the bank (in case of a transfer between accounts of the same bank) as AR, but this wouldn’t be practical because of the obvious concurrency contention issues.

    How would you handle this? Is this a situation where you would violate the rule? In that case isn’t this an issue which occurs often enough that it should be an explicit exception?

    Interested in your thoughts, thanks in advance!

    • Do banks actually ever reconcile two accounts in a single transaction? While that may be a schoolbook example of why to use a transaction, it practice I think you would find that the industry doesn’t do that. In fact, how could two different banks unrelated to each other reconcile funds transfer from one to the other in a single transaction? They’d have to share some short of cross organizational global transaction, and that would have to be true of tens of thousands of banks around the globe. Basically, that’s not going to happen.

      This is actually a great example of why eventual consistency is necessary.

      Vaughn