His opposition to repositories is well documented on his blog. It basically 
comes down to not hiding NHibernate behind another layer of abstraction. 

Repositories, from Martin Fowler's point-of-view, are supposed to abstract data 
access behind an interface that appears to the consumer as an array, or 
collection. My repositories, for example, appear as IEnumerable<T> collections 
to the application.

As you work with a system you start to add specialisations to the collection's 
data set through extra query-style methods. You've now effectively turned your 
repository in to a DAO, and you're leaking database concerns (querying) into 
the collection pattern.

Ayende advocates not hiding NHibernate behind an abstraction as it's already an 
abstraction, and all you're doing is closing off your application to all the 
power available in NHibernate, and possibly exposing yourself to performance 
bugs like N+1 etc.

So, looking at it from his point-of-view, I can see what he's saying, and I 
agree with him to a point. If all you're doing is adding lots of methods to a 
(no longer) repository to expose behaviour that NHibernate gives you natively, 
then you're just making more work for yourself. Just use the ISession directly.

However, if all you need is simple collection-style access to data in your app, 
then roll with repositories. It's not black and white, you have to feel it out 
for yourself. 

Thanks,
Geoff.


On Friday, 9 March 2012 at 5:55 PM, Simon Dingley wrote:

> On 9 March 2012 06:51, Jeffry Morris <jeffrymor...@gmail.com 
> (mailto:jeffrymor...@gmail.com)> wrote:
> > Ayende said repository pattern bad. So no matter your success, community 
> > say bad.
> Perhaps I am yet to find out for myself but I would like to understand more 
> about why this view is taken by Ayende and the community and what sort of 
> approach they suggest as an alternative or preferred route. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibernate@googlegroups.com 
> (mailto:fluent-nhibernate@googlegroups.com).
> To unsubscribe from this group, send email to 
> fluent-nhibernate+unsubscr...@googlegroups.com 
> (mailto:fluent-nhibernate+unsubscr...@googlegroups.com).
> For more options, visit this group at 
> http://groups.google.com/group/fluent-nhibernate?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to