Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • As always great answer; however, what about being able to query for a report? Somewhere you would need to keep a list of transactions that have no effect on the business logic. For example, an inventory system.. You want to see stock levels over time (not business logic as you alluded to); however, I need to track where purchases, sells, and stock adjustments happen. So you're saying to keep this out of the domain model? Also, you're duplicating data because if you keep a stored integer of StockAvailable and then have the transactions as well, you might have data that gets out of sync. Commented Nov 27, 2018 at 22:08
  • Another example would be banking Accounts that don't store the current balance but keep a list of transactions that are then used to compute the balance. Is this list of transactions considered domain logic or reporting? Commented Nov 27, 2018 at 22:10
  • @keelerjr12 I think it may be useful to treat/understand reporting as a read model. In this way duplication/denormalization is to be expected. Of course, eventual consistency may also be a necessary trade off. In regard to your Account example, the data can be both. The Domain is responsible for mediating how new transactions enter the system or how they change, and Reporting can read the data for whatever purpose is necessary. The focus of DDD is on the behavior of a system. Read models can be generated freely ad-hoc. Commented Nov 28, 2018 at 5:20