DDD and Aggregate Transaction Boundary

后端 未结 1 895
野性不改
野性不改 2021-01-14 18:06

Let\'s say I have an object called document and it has bunch of children in form of images, audio, video etc. So a user of my application can create a document by typing som

相关标签:
1条回答
  • 2021-01-14 18:45

    Consistency boundaries (I prefer that term over "transaction boundaries") are not a concept that specify the granularity of allowed changes. They tell you what can be changed atomically, and what cannot.

    For example, if you design your documents to be separate aggregates than the images, then you should not change both the document and the and image in one user operation (even when that's technically possible). This means that aggregates cannot be too small, because that would be overly restrictive for a user. They should however also not be too big, because only one user can change an aggregate at a time, so larger aggregates tend to produce more conflicts.

    You should try to design aggregates as small as possible, but still large enough to support your use cases. Thus, you'll have to figure that out yourself for your application with the rules above.

    So both approaches that you mention are valid from a DDD point of view.

    0 讨论(0)
提交回复
热议问题