Search This Blog

Thursday, February 14, 2013

Broken By Design:

[Open Letter to Microsoft ADO.NET Team, re: DataTable DateTime column "mode"]

I just want to say what an unfathomably POOR design choice it was to make "Unspecified Local" the default -- actually I question whether that mode should even exist at all!
Given that, prior to SQL 2008, all stored dates were effectively mode "Unspecified" (and that, in practice, the vast majority of DB-stored date values are still that way today) "Unspecified Local" is the worst case choice, it sets up data mayhem, and adds meaning to the word quirky.

It would've been nice if DateTimeKind could've been respected when assigning DataRow field values -- surely the offset could've been adjusted accordingly per row -- but nooooo, "you get one DateTimeMode for the column, across all rows, and you'll like it!"

What's worse, this mode literally begs for data corruption, during that interim while a developer has yet to perceive he has been thrown under a bus! For those unlucky enough to test on a server in their same time zone, the false sense of security this mode fosters is nothing short of negligence.

Until this moment I have been very pleased with ADO.NET, it's capabilities, flexibility and performance. Now I must question all assumptions, because as design choices go, "Unspecified Local" as default mode is just plain idiotic.

The icing on the cake is that this hasn't been changed over 2 releases of the framework -- consistency is only a virtue if you're not a screw-up! I'm sure the concern is the havoc it would wreak to change it at this point (pity that wasn't considered prior to 3.5's release) but there is a way to make it infinitely more usable, without breaking all the code that has surely been written to skirt this lunacy, so simple it's childish:

Add a DefaultDateKindMode directive, and change DataReader to respect it. Simple. Efficient! Not painful for the developer at all (forget excruciatingly so.) Let us make an intelligent, informed choice when we create a DataTable (because you are obviously incapable of such.)

No comments:

Post a Comment