Keeping a domain model consistent with actual data

Posted by fstuijt on Programmers See other posts from Programmers or by fstuijt
Published on 2012-11-21T13:11:01Z Indexed on 2012/11/21 17:15 UTC
Read the original article Hit count: 207

Recently domain driven design got my attention, and while thinking about how this approach could help us I came across the following problem.

In DDD the common approach is to retrieve entities (or better, aggregate roots) from a repository which acts as a in-memory collection of these entities. After these entities have been retrieved, they can be updated or deleted by the user, however after retrieval they are essentially disconnected from the data source and one must actively inform the repository to update the data source and make is consistent again with our in-memory representation.

What is the DDD approach to retrieving entities that should remain connected to the data source? For example, in our situation we retrieve a series of sensors that have a specific measurement during retrieval. Over time, these measurement values may change and our business logic in the domain model should respond to these changes properly. E.g., domain events may be raised if a sensor value exceeds a predefined threshold.

However, using the repository approach, these sensor values are just snapshots, and are disconnected from the data source. Does any of you have an idea on how to solve this following the DDD approach?

© Programmers or respective owner

Related posts about architecture

Related posts about domain-driven-design