February 11, 2008
Simple Object Persistence - When, Goddamit?!The latest version of NHibernate is pretty sucky. Now you have to explicitly declare any properties or references to other types of persistent objects as lazy-loaded in the mapping files - even for primative types like integers and strings. If you don't, it throws a wobbly and tells you to declare your getters and setters - and, for reasons I can't fathom, some other public methods, too - as virtual. For some reason that also applies to identity fields.
Anyway, it got me to thinking - why can't we just figure this whole object persistence thing out? Why isn't it ever simple? Why isn't it ever robust?
There's always, always some fiddling and fussing and general scratching of heads involved, and your model code always, always ends up looking somehow different in the end.
It makes me mad!
Why can't it be as simple as:
Code: "Hello, simple, no fuss, reliable persistence framework"
Framework: "Hello, clean code that is not in any way munged to make persistence workable"
Code: "Could you put this object somewhere safe for me, please?"
Framework: "Sure. Here's a cloakroom ticket so you can get it back later, exactly as it is now"
Code: "Thanks. Gee, that was simple. What am I going to do with all this spare time?" ---CODE GOES OFF TO DRINK BEER AND DOWNLOAD PORN ETC
LATER THAT EVENING...
Code: "Hello again, simple, no fuss, reliable persistence framework"
Framework: "Call me Phil"
Code: "Hi Phil. Could I have that object I gave you back?" ---HANDS PHIL THE TICKET HE GAVE HIM EARLIER
Phil: No problem. Here you go.
Bish, bosh! Job done!
Now, yes, I know some of you are going to shout back that what i've just described is effectively object spaces. But even they are pretty sucky. They require mucho plenty infrastructure and configuration files and never quite end up being the simple, transparent solution we'd hoped for. Largely because they try to map on to so many possible back-ends.
But what if the goal isn't to stick our object data in Oracle or LDAP or SQL Server or an XML object database? What if we just want to put our Java or .NET or C++ or SmallTalk or - god forgive us - Visual Basic objects somewhere safe where we can get at them later?
99% of the time, I know that's all I want...
Posted 11 years, 2 months ago on February 11, 2008