Re: Repositories Global only or contextual?

Thomas Presthus <[email protected]>
Newsgroups gmane.comp.programming.domain-driven-design
Organization Erus Encodia AS
Message-ID <1390389301.32405.6.camel@thinkpad>
On Tue, 2014-01-21 at 16:35 -0800, [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 beg to differ. According to Eric Evans in chapter 6 of the blue book:
«A REPOSITORY lifts a huge burden from the client, which can now talk to
a simple, intention-revealing interface, and aks for what it needs *in
terms of the model*. To support all this requires a lot of complex
technical infrastructure, but *the interface is simple and conceptually
connected to the domain model*.» (my emphasis).

The implementation of a repository is thus an infrastructure concern,
but the interface of the repository is in terms of the model. I think
leaving repositories alone in the infrastructure might disconnect the
language of the repository's interface from the one of your domain over
time. I therefor consider it a best practice to model the interface of
the required repositories in the domain, and implement those interfaces
in the infrastructure.

> 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).

Lazy loading is an optimization mechanism that should only be used if
required. And if it's required, it should not be a part of the
repository's published signature, but rather an infrastructure concern
that is encapsulated and hidden from the calling client.


Thomas.



------------------------------------

Yahoo Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/domaindrivendesign/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/domaindrivendesign/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo Groups is subject to:
    http://info.yahoo.com/legal/us/yahoo/utos/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.