Jun 19, 2008 / nhibernate ~ .net ~ development ~ writing
NHibernate in Action: My favourite chapter

Having done a preliminary review of NHibernate in Action, Chapter 10 last night, I'm now working on the actual edits. It's been fun!

Chapter 10 - NHibernate in Action

This is a great chapter, in fact, I think it's my favourite. It focuses on architectural issues, and I always find those the most fascinating. We're talking about separation of concerns, layering applications, whilst giving lots of code samples and real-world advice.

This chapter cleverly starts with a "big ball of mud" example, where one method involves executing a use case, including data access, session management and business rules. The chapter then goes on to show how you can tease apart the responsibilities, pushing them into separate layers. It's one of the clearest approaches to describing these activities I've come across.

Chapter 10 also talks using NHibernate along with ASP.NET sessions, and how you can leverage some of the newer features of NHibernate.

I was at first surprised that Kuate chose to use the DAO pattern in the examples, rather than the Repository pattern (ala DDD). In retrospect this isn't a book about DDD, so explaining those concepts might have used too much ink. DAO still gives a clean separation of concerns, and nicely expresses the techniques involved whilst not requiring huge amounts of background explanation. A good choice. (Note that I did chuck in a small explanation of overlap between these approaches)

This chapter also talks about business transactions that span multiple requests. I'm gonna read it again, because not sure I'm completely in agreement yet! I'll be asking Pierre Henri to help me ensure I've understood it correctly. It seems that the book is recommending the session-per-conversation pattern, but that means keeping state around for a long time, and that sets off alarm bells for me.

All in all this chapter is great, it nicely intertwines the knowledge and techniques presented in the rest of the book with some good architectural principles. I'm up to page 22, so only 15 more to go!

You may also like...