Wednesday, March 25, 2009

Personification of a startup script

Every morning when I log in, the startup script at the government department I work at prints this to the screen: "Good Morning Daniel". And if it is afternoon, it prints "Good Afternoon Daniel".

I can't imagine that a greeting like this would be part of government policy, or even exist in any departmental guidelines or any other document. Most likely, some developer somewhere in history thought it would be cute. And now this greeting appears to every single government employee every single day.

I don't like it.

It's not just because I don't agree that it's cute. Or just because it's something that I have no option of turning off or ignoring. My dislike is much more intense than that, I view this as an affront to my humanity. This computer is a tool to me - nothing more. The greeting it gives me is something that is fundamentally human, it only belongs to humans and should never be uttered by a personified machine. The startup script doesn't care about me, the machine doesn't care about me, and the programmer who wrote it obviously doesn't care about me. So why write it?

Sometimes humans say this phrase to people they don't like or care about just to be courteous, or out of habit. But in every case it at least involves one human acknowledging the existence of another. Both the computer and this startup script do not even acknowledge my existence - nor can they, so they have no right to use this phrase.

I don't mind when things are written in a conversational style, or even when text is presented in a first person manner, as if the (human) writer of the text is addressing me personally. But for some long-gone programmer to write a "Good %timeOfDay%, %userName%" script to somehow personify and friendlify the startup screen and think that it will actually mean something to me is the most impersonal, condescending, thoughtless and insulting thing that a programmer could possibly do.

If you are a programmer, please don't personify your scripts (unless you are being ironic or something).

And have a nice day.

P.S. Friendlify is not a word - and nor should it be. It is just a ridiculous made up word that attempts to express a concept that is ridiculous: to make something inanimate friendly.

Thursday, March 19, 2009

LazyInitializationException has a misleading error message

You'll get a LazyInitializationException if you try to load an object from Hibernate, clear the Hibernate session, then lazily initialize a collection on the object like so:

Customer customer = loadCustomerUsingHibernate();
hibernateSession.clear();
customer.getAddresses(); // LazyInitializationException!!

In this situation, the session still exists and has not been closed. Yet the default error message on LazyInitializationException proclaims: "No session or session is closed"

This error message is misleading and led me up the garden path. The cause of the exception here is that the first level hibernate cache has been cleared, and customer is now a detached object. It has nothing at all to do with a closed or missing session!

I guess if you view it from the perspective of the detached customer object, there is no session to be found, so the message sort of makes sense - but I usually view things from my perspective (the developer), and when it says there is no session it is confusing for me.