Domain Model and Querying

Posted by Tyrsius on Programmers See other posts from Programmers or by Tyrsius
Published on 2012-12-19T06:51:21Z Indexed on 2012/12/19 11:13 UTC
Read the original article Hit count: 193

I am new to DDD, having worked only in Transaction-Script apps with an anemic model, or just Big Balls of Mud, so please forgive any terminology I abuse.

I am trying to understand the proper separation between the domain model and the repository. What is the proper way to construct a domain object that is coming from a database, assuming the (incredibly simplified) need to query for objects by status (returns enumerable), or by ID.

  • Should a factory be building the objects, exposing methods for GetByStatus() and GetByID(), using a DIed repository?
  • Should a repository be called directly, knowing how to build a domain model from the DTO?
  • Should the domain model have a constructor for get by ID, using a DIed repoistory to load the initial state, using some other (?) method for the list?

I am not really sure what the best way would be, and this question has an answer advocating each one (these are certainly mutuallu exclusive).

© Programmers or respective owner

Related posts about design-patterns

Related posts about domain-driven-design