Re: Repositories Global only or contextual?
Caleb Cushing <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <CAAHKNREb_FH2dvRH0aSM-z-o7a4mXou1F3YQ6GgyXqe8DBgkUw@mail.gmail.com> |
On Tue, Jan 21, 2014 at 6:35 PM, <[email protected]> wrote: > Repository is not really a concept from your domain. That's an > infrastructure concept [so that domain can make side effects ;) > I thought that repository implementations lived in infrastructure, whilst the repository interface lived in the domain. Al > While adding methods to it seems like modeling a domain - since methods > have name from the domain, all it really is a glue between application and > the domain. > > > Having said that, lazy load is another story. While you could use > signature to implement lazy load. since you are using Java, your signature > would not look too nice (in .NET you could leverage IQueryable from LINQ - > which looks much better). > > > So, either pick a signature which can be used for lazy loading - which Set > is not, or explain your requirements somewhat better, since maybe you want > to call this method on repository on a later time, instead of calling it > early and expecting result to materialize at a later time.I > IIRC IDDD suggests that Set is the interface that matches a Repository, obviously if the implementation is sitting on a database, most of the time you would not load all of the aggregates into memory at once. Unless you know what the max number of rows is going to be. The problems is that Tasks in theory represents all tasks... then I have a, we'll call it UserTaskBacklog that is the set of all user tasks for all time, Tasks cannot be removed only completed or obsoleted. Then there's a ToDo( Date ) which is a Set of uncompleted, and unobsoleted tasks, but restricted to the amount you might be able to complete in a day (this could fit in memory). My concern is that since tasks are never removed from the backlog, loading all of them at once could be disastrous down the line (in a dear magento, why doesn't your RPC API allow me to specify a limit, sort of way). I could make the implementation of the UserTaskBacklog know how to access the database, but I feel like i"m just creating another repository, and then shifting parts of my model implementation into infrastructure. Perhaps I've entered CQRS territory? or perhaps I should just make UserTaskBacklog (whatever interface it settles on) have an infrastructure dependent implementation? -- Caleb Cushing http://xenoterracide.com Calendar: https://www.google.com/calendar/embed?src=xenoterracide%40gmail.com&ctz=America/Chicago