Edmonton .NET User Group Meeting – August 23 – James Kovacs – The nHibernate Mafia and the Persistent Ingorant Domain Model

The EDMUG presentation by James was quite informative. I have only ever read about the inner workings of nHibernate and only been following the numerous discussions on blogs so my understanding was, before tonight, only at the 1000 ft level. Last night I had a couple of my suspicions confirmed: 
  1. The model for persisting to the database is fantastic from an architectural perspective. Persistence ignorance is, in my opinion, a very clean model for removing meta information about a domain from the domain itself.
  2. With this, you are trading programming in C# (rolling your own mappings) for writing executable XML (okay, it’s not executable XML in its purest form.. but let’s get past the semantics).

One of the comments that James made was "Once you get it set up.. it works great" (after numerous runtime exceptions had been thrown while getting the ad hoc demo up and running1). Another was what he was mentioning was his hopes that Entity Framework from Microsoft would have been, "nHibernate with better documentation". These two comments, combined with what I saw as far as setting up mapping (read "config") files reminded me of the pain I undertook to try and figure out how to get Apache to run Tomcat and WebDAV (to host a Subversion repository) for the first time when both were quite new to the LAMP stack. Hours and hours of tinkering with config files, waiting for the inevitable runtime error (would have made me happier if it were design time rather than run time, let me tell you) until that eureka moment hits and you finally get it right. Just like James‘ comments, once you got it working, it worked great!

James did allude to tools out there that can help you with the mappings and will generate/manage them for you. For some reason I kept thinking of BizTalk whenever this was mentioned. Code generators have always tended to have their issues and never sat well with developers.

<tangent id="first">This is one of the main reasons I find blogs so valuable. Someone is experiencing the same pain I am because of un- (or poorly) documented products that require extensive configuration that’s not usually easily tested or debugged. Just look at all the resources that are now available to get WebDAV up and running on Apache. Note that the first result is NOT from the Apache or WebDAV web site.</tangent>

So, where does this leave me? Currently I am in that "wait and see" mode. James continued his demonstration to show Castle Active Record which builds on (or can be used to build on) nHibernate. Though I am likely wrong on this, nHibernate just gives me that sense that it is a very powerful low-level utility that is going to have a nicer face put on it. I envision its evolution to be something like how the XML serialization happens under the hoods in most Web Services implementations. You CAN go down to the XML level if you want to/need to tinker down there but for the most part you can let it be, generate your proxies and let it do its thing under the hood. So, who knows? I certainly don’t.

<tangent id="second">I like the "under the hood" aspect of XML serialization in Web Services because I don’t have to worry about XML Schema. I find the consistency between choosing a data item to be an element or attribute tends to no be (consistent). I prefer it when I don’t have to worry about conforming to someone else’s (or even my own) schema because that complexity is taken care of in a consistent manner by the proxy generator and I can just work with the objects.</tangent>

So, over-all, the presentation was fantastic in that it was very informative and showed me something I’ve only been following and understanding nHibernate from a high level. James did a great job with the presentation. I love ad hoc technical presentations because it tends to REALLY show just how "easy" the technologies are to use that the presenter (expert) is talking about. I also have to thank the EDMUG for organizing and preparing the event as well as supplying, yet again, great door prizes. I was fortunate and won a Windows Vista Business licence that I am planning on using on a VM in the near future.

1This is, certainly, no reflection on James‘ skills as a developer. He is VERY skilled, VERY talented, and knows his stuff. It is meant to exemplify the fact that even seasoned developers don’t just sit down, start writing this stuff, and get it right the first time. Does this reflect on maintainability? *shrug*

Note: The cheekiness of the <tangent> tags is intentional.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s