Okay, so if you're like me your getting sick of the “how fast can we get a book to market” approach with .NET development books these days. As it is probably seen in other genres as well, I can only attest to .NET books, as those are all I read. Today I finally boiled over after discovering one of the most blatant examples of untested code I have seen. So here I am minding my own business when an analyst approaches me for help with some ADO code working with DataSets and DataViews. He indicates that he has been working with the code for over 2 hours and cannot get it to work. He's damn near copied the exact example of the popular “ADO.NET in a nutshell” O'reilly published book, written by Bill Hamilton and Matthew MacDonald (pg 127 to be specific :). The code:
-----------------------------------------------------------------------------------------------------------------
DataSet objDS =
new DataSet();
DataTable objDT =
new DataTable();
SqlConnection objConn =
new SqlConnection("SERVER=localhost;DATABASE=Northwind;UID=sa;");
SqlDataAdapter objDA =
new SqlDataAdapter("select * from customers",objConn);
objConn.Open();
objDA.Fill(objDS);
objConn.Close();
DataView objDV =
new DataView(objDS.Tables[0]);
objDV.RowFilter = "Country is NULL";
foreach (DataRowView row in objDV)
{
row.Delete();
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
You're probably thinking what I was thinking, “I don't think that logic will work”. I quickly put the code, straight from the book, and ran it. No error. Next I went to the DB to check the Northwind DB Customer table for records with NULL country entries, and as I suspected, there were none. I quickly added a few rows with NULL country fields, and what do you know. The code bombs. So here we have a “perfect example” in a book that was most likely debugged, but would not error because the damn code never even reached the guts of the foreach loop. What a crock. The funny thing is, that the code most likely passed through many a developer's hands in testing and passed. That being said, my only request is: “If you're a developer and your stupid, stop teching published material. Just because you have a MSABADCESAAA does not make you smart.” I ahve learned that QA in .NET books right now is severely lacking. Publishers, please stop putting out crappy code samples. If we were smart, we'd be billing these guys for unproductive time :).
Ahhh, finally somewhere to lay my rants to rest. While I am unsure as to the frequency of my posts, I will most likely try to write something daily. Anyway, let me introduce myself as I will now pretend that others who do not know me may read this. I am a .NET developer specializing in ASP.NET web architecture and development. I have been working with Microsoft technologies for over 6 years and have been involved1 with .NET since it's infancy. I am currently working as a contractor for whoever is paying more, and continuing to build my knowledge and fuel my own desire to know everything about nothing. If you need to know more than that, check out joeolsen.com. The following are my little comments for today:
1) Avalon is crap, bring on Aurora
2) Never underestimate the under developed product knowledge of proclaimed professionals
3) Cold Fusion is the spew between Gollum's toes
Now I leave you with an excerpt and poem written by a chief editor of O Reilly, Frank Willison, in 1997, during the height of all the Java hoopla (which is reminiscent of the .NET hoopla today), ever reminding us that history most definitely repeats itself.
Frank's note to the editors:
“What network-enabled muse is visiting the minds of previously sensible ghost writers and filling them with the irresistible desire to peck out another introduction to a partly formed network programming environment? I wouldn't want to mislead you into thinking that I am immune to this impulse; no, I, too, have been smitten. Here is a sample from my upcoming book, a series of tutorial sonnets entitles Learn Java in 14 Lines.“:
Alas! I Married a Java Applet!
My parents plead with ardent supplication,
That I should, if I marry, web a lass.
But I chose you, a Java application,
And one, I blush to say, not from our class.
At first, you were both colorful and quick,
And on your speedy access I did dote.
Though on your Wedding Day we seemed to click,
O'er time, you grew increasingly...remote.
It seems that other users cam to search you,
O'er all of us, your favors did spread.
Through virtual, you knew not much of virtue,
Our love affair left hanging by a thread.
Romantic love with applets is most terrible.
I wish I weren't installed so network-shareable.
--Frank Willison
1 I use “involved” opposed to “working” to represent the fact that working in .NET has turned out to more of a relationship with me as opposed to just work over the past 2+ years. Sometimes it even feels as though my second wife is web technology, and her beautiful brown eyes are .NET.