I Heart Nebraska
by in Feature Articles on 2005-06-30public string GetStateAbbreviation(String stateName) { String stateAbbrev = stateName.ToUpper(); if (stateName.Length > 2) { stateAbbrev = stateName.SubString(0, 2); } return stateAbbrev; }
public string GetStateAbbreviation(String stateName) { String stateAbbrev = stateName.ToUpper(); if (stateName.Length > 2) { stateAbbrev = stateName.SubString(0, 2); } return stateAbbrev; }
A long while back, an anonymous reader sent in a block of code that, at first glance, looked like well-written VB6 code implementing some fairly complex products catalog. There was no background or remarks with the submission (which, by the way, is very helpful), so I kinda just tossed it in the "Look-at-this-later" folder. I finally got around to checking it out discovered why it was sent in ... I'll leave it as an exersize for the reader to find this same reason ...
Although it's not coding, Max M. sent in this story that I just couldn't pass up ...
Due to the high-security requirements of our organization, we require that all incoming and outgoing webservices go through a secure VPN tunnel. Normally, this isn't a problem. We have our network guys talk to their network guys, they do their thing, and us developers can't even tell the difference.
Chris Jefferson has been reading The Daily WTF for a little while now and often wondered how many of the posts here were made up. Then he came across a "don't touch" system; you know, the type so sensitive to changes that even adding too many spaces between compiler switches will cause a complete melt down. The C++ folks with templates experience will definitely appreciate this most ...
A couple months back, I posted a handful of different error messages that readers sent in. Quite a few of you replied to the post, adding even more error messages. That worked out very well, so here's to trying it again ...
First up is TomA, who came across this message while installing Britannica 2003. Some people believe in simply disabling the Minimize button. Others just tempt you with clicking it. Ironically, the installation failed despite the fact that Tom didn't click the "-" ...
It's time once to play Spot The WTF. You should know the rules by now; just see how many WTF you can find. I counted five. I'd rate the difficulty of today's exercise the same as that of finding the screaming man in Edvard Munch's Scream.
There are those who believe that the GUID is the greatest innovation in information technology since twos-compliment, using them to identify everything from cars to invoices to llama. Then there are those who have to work with and maintain systems built by the wish-I-chould-change-my-name-to-a-GUID type. Perry Pederson falls in the later camp and gets to work with code like this ...
David DeLoveh came across an ASP 3.0 developed by some programmers with decent intentions: make the site easier to maintain by separating the VBScript code from the HTML. They figured that things like <%=OrderTotal%> embedded in HTML would confuse web designers who may want to update the site. So, they developed a system that would read files from disk, process them, and write the contents out. They even came up with their own tag system that would be sure not to confuse a designer: instead of the complex <%=OrderTotal%> designers would use @@ORDERTOTAL@@.
It worked out all well and good until people actually used the site. As it turns out, ASP isn't really designed to implement itself. It tends to slow down when reading lots of files from disk, storing the content in variables, doing multiple replacements, and writing out the content ...
I'll bet that when you were in school, you never thought you'd be sitting in a conference room, having a discussion on whether you should use "possibly", "perhaps", or "sometimes" as the fourth value for a yes/no flag variable. In fact, I'll bet that had you known you would have been in such a situation, you would have gone into accounting instead. No less, this is where Josh was recently, when his team was trying to figure out how to add another role to a large ColdFusion based application in which changing the architecture was not an option ...
It's days like this where I really think we need to be careful about exposing certain words and concepts we expose to "certain" programmers. What tends to happen, quite ironically, is that the "certain" programmer somehow manages to recreate the exact problem that a technology was designed to solve within the confines of that technology.
Case in point, Matt sent in what happened when his predecessor heard the word "extensible." No surprise, the programmer was actually able to completely negate the entire purpose of functions by using a function ...
Whoooo boy, that was a bad pun of a title; I think I may have actually topped Count Rowula. Anyway, today's example is from Lynn Rogala, who was tasked with figuring out how to merge three additional marketing databases into their existing system. The data folks tried just merging the data, but that caused the system to become incredibly slow. After a little bit of digging, Lynn discovered that the original programmers didn't really believe in using the WHERE clause when it came to SELECT statements ...
Mike W. was fresh on a new project and looking through the code base, trying to get an understanding of the architecture and how the system does its things. I believe that "disappointment" was his official reaction upon discovering how the architects designed the system's framework. As it turns out, they were a bit uncomfortable using abstract classes; maybe some one, some day will want to create an instance of the class. And they flat out didn't like interfaces; I mean, really, who uses those things anyway? Instead, they created based classes comprised entirely of "unusable" virtual methods ...
Phew! Sheesh, I'm still feeling yesterday's SQL-Cookie post, so we'll have to tone it down just a bit today and with this submission from Gavin. He was maintaining an ASP-based web application and couldn't seem to figure how where all these variables (sTmp, iI, etc) used throughout the code were coming from. They weren't declared, and Option Explicit was on, so it just didn't make sense.
Buried behind three levels of include files in the footer, Gavin finally found temp.inc ...
As you read this short introduction, I'm guessing that you can see today's code in your peripheral vision and are wondering, Tossing Your Cookies? What does that have to do with a huge, ugly SQL statement? I'll let the combination of "Cookies" and "SQL" sink in for a moment ........ ahh, there it is. And yes, it's exactly what your thinking. It's from the system that Chris F inherited and is used to redirect the browser to a results page, execute the "SQL cookie" (as the sa user, of course), and display the results in a grid.
Let's take a quick tour of certain programmers' remarkable abilities to take things so simple and turn them into WTF ...
First up, and I must say this one takes the cake, is from Billy. As some background, these constants were defined in every class in the Java project. These were used throughout the system in place of their primitive boolean counterparts ...
As I mentioned a couple weeks back, I love it when you can extrapolate how the rest of a system must be designed based on seeing of one little piece of code. Betul sent this in and I have to say, I'm not so sure I want to even fathom how the rest of the system must look .... and sadly, this is not part of some data cleaning, migration, transfer, or other similar script. It's actual, real-live production code for determining if a string is null ...
It's time once again to check in with our dear colleague Colin A. Bradley. If you remember from previous posts, Colin is apparently the victim of some cruel practical joke known as the accounting system Payback. While maintaining this treacherous application, Colin came some tables of the following form ...
It's not that I'm against highly paid consultants. Call me old-fashion, but I really do believe that leveraging a strategic partnership with a proactive service organization can actually synergize and streamline mission-critical objectives. But no less, I do love sharing stories like this from Greg ...
After starting a new job as a Senior Developer, I was given the task to track down a problem in one of the company's web applications. Users had been reporting for six to seven months that a particular web page had been taking as long as eight minutes to load.
Today is one of those days were you're gonna think, that can't possibly be real ... no seriously ... it can't be! But it is; Chris F sure can attest to that. He found this while investigating connection pool exhaustion problems in an application he was unfortunate enough to inherit. The author, apparently, thought that converting a string (that oddly resembles valid code) to an integer would magically find the execution context and perform these calls on the appropriate objects. Worse still, it's only the tip of the iceberg ...
Steven Rockarts was working on an old mainframe system and couldn't seem to figure out how to purge an already running job. He fired up the help function and found himself bursting out in laughter after seeing the CD and CDA commands. Note that a certain level of immaturity may enhance your help-screen experience ...
The introduction of AND, OR, and NOT operators to programming languages has really made code a lot easier to read and write. By now, it should be no surprise that certain programmers prefer not to deal with the plethora of Boolean operators and their inherent complexity, instead utilizing elaborate, nested IF blocks. But what makes today's example (from David Koontz) so neat is that the proper solution is commented right above the actual solution ...