Programming, Technology

Abbreviations Considered Harmful

I recently struggled for several hours over a sorted ASP.NET GridView control which was failing to behave properly. I found that on PostBack for the LinkButtons, the SortCommand was returning expressions such as “LocationDesc” and “PositionDesc”. I was confused as to why the sort direction was attached to the expression when it was already part of the SortDirection property of the EventArgs object, and assumed it might have had something to do with the way the other developers were persisting the sort data in ViewState. So I wrote a function to strip out the “Desc” from the sort expression, but as I got further in my testing, the database was telling me that “Location” and “Position” weren’t in the table. I checked to see if it was a matter of them not being included in the select statement vs. not being in the actual database table. When I looked at the database table, lo and behold, the fields were called “LocationDesc” and “PositionDesc”. Apparently “desc” is short for “description” (which is itself redundant). This results in such obviously horrid SQL statements as select * from [mytable] order by locationdesc desc. Terrible.

So I made a request to the rest of my team: let’s not do this anymore, okay? But they shot me down, as they always do. “We’ve always done it that way,” or, “That’s the naming convention they used in the legacy tables.”

It doesn’t matter if it sucked in the old days. That’s no reason to keep sucking! The fact that we’re still fixing things implies that what was done in the old days was not good enough. Let’s try not to suck anymore, okay?

“In general, you should not use abbreviations or acronyms. These make your names less readable.” —Microsoft


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your 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 )

Google+ photo

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

Connecting to %s