I agree with pretty much everything Billy said but if you are like I was when I started using Sharp Lite, it is still a little confusing. The architecture probably isn’t appropriate for every project and it is up to the team to determine if it is a good fit, but I knew so little about the architecture or even the technologies it used that it was hard to evaluate whether or not it was appropriate. My team was coming from the world of classic ASP and didn't really have any experience with nHibernate, MVC, Dependency Injection, or even a good layered architecture. I've been working on a project using Sharp Lite for a couple of months now though so I'll share my thoughts.
For us, the architecture has been invaluable, primarily because it has allowed us to follow a well thought out pattern and achieve success, while slowly learning about all the technologies used (e.g. nHibernate). I think we would have had a lot more trouble starting this from scratch. After using it for a while, I feel pretty confident with most of the techniques and libraries being used, but the architecture allowed me to ease my way into it.
I do agree with Ayende that following the original store example seems to encourage 'walking' the domain model. This is basically accessing sub-properties of the model that are lazy-loaded, so they cause a call to the database which leads to the n+1 problem Ayende talked about. The latest CaTS example and Greenfield documentation indicate that a solution will be given to this problem, but I don't think it is there yet. I'm guessing some sort of ViewModel/Dto that has these items pre-loaded but I'm not sure. My current application is issuing quite a few calls to the DB but in my situation it is okay. We have a small group of users and the DB is on the same server as the app so I'm willing to hold off and fix it when it becomes an actual issue.
Ayende's other primary criticism is the abstraction of the data access; I think Billy covered that pretty well so I won't go over it again. I appreciate having the nHibernate particulars well confined and think it does make things pretty clean and I definitely wouldn't want to shove a bunch of that code in the controllers. In fact, I'd be tempted to move more of the data access into the tasks and use ViewModels exclusively in the controllers. This would allow me to only pass the data necessary or eager load more of the data.
In any case, I only have one real disagreement with Billy and that is about the maturity of the nHibernate LINQ provider. The documentation and sample code say that you should rarely have to move beyond the LINQ provider (e.g. Query<>, HQL, custom stored procedures) but I have had to do just that in multiple spots. I'm even using the unreleased nHibernate 3.3 because it fixes some issues I'd consider pretty basic, like multistep joins:
https://nhibernate.jira.com/browse/NH-2905
This has also stopped me from solving the lazy-loading issue, since it requires nHibernate specific calls and I haven't figured out how to do that without making the higher levels dependent on nHibernate. Hopefully Billy will come through with something great (or let me know what I'm missing).
I've had some expirience in abstracting away fetching calls with LINQ to NHibernate. You can see example here.
Maybe it should be included in project template?
2012/3/12 Billy McCaffertyPatrick,
2012/3/12 Billy McCaffertyPatrick,