Recent Articles

Dec 2004

Not Quite Selecting a Case

by in Feature Articles on

Well, I was going to try to do some fun, year-end post. But, with server troubles and aparantly no one working today, I figured I'll just share with you code left behind for Rob to maintain from a (you guessed it) highly-paid consultant.


Avoiding Magic Numbers

by in Feature Articles on

The term "Magic Numbers" generally refers to numeric constants embedded in code that serve an essential but often difficult to determine purpose. Avoiding code like "if (table.columns(8).row(12) = 772) ..." is generally regarded as a best practice. But I'm not sure Matt's colleague, however, grasped that concept too well ...


One View to Rule Them All

by in Feature Articles on

Ultra-complex query execuation plans can be expected (and are quite the norm) in data-warehouse querying systems. But, this isn't example what you should expect to see in a production system ... (zoomed out to the max) ...


Innovations from the Inventor of the "ElseIf"

by in Feature Articles on

James Ingram shares one of his most impressive experiences ...

I had some legacy code originally written by a highly paid consultant. Among his innovations were that all his "Cancel" buttons were on the left, and all his "OK" buttons on the right; the opposite of the MS standard (and every app I've ever seen). The users had gotten used to it, so we couldn't change that.


tblCalendar - Editor's Edition

by in Feature Articles on

According to the hit counters, 2/3 of the regular visitors to the site are still on vacation. So for us unfortunate few stuck at work, here is one of my favorite, yet least-viewed posts from a while back.


I hereby issue a challenge for you to justify the actions of Programmer X, as described by Jakeypoo:


Wrapping up the IntWrapper

by in Feature Articles on

Looks like we're back up and running. Seems like it was a transformer that blew, causing total power outage of the data center (which would explain their lack of phone support). Ah well.

So here goes post #12. Have a happy Festi-kwanz-ukah-mas!



Return of IsTrue()

by in Feature Articles on

Holy fricken' time-for-a-new-host! Jeeze ... the idea with going dedicated was to improve reliability ... but the site has been down since this morning. So if anyone knows of a good data center offering a package for around $150/month who will install Small Business Server, please let me know.

With that aside ... here is a look at Post #4 ...



Function Batman() (Again)

by in Feature Articles on

With the year-end holidays and vacations, I've noticed there's a lot less blog reading going on. In that spirit, I'm thinking of posting some repeats that most of you (according to the stats, atleast) have not seen before. So without further ado, here is post #5:


As a certified Überprogrammer, I get quite annoyed with inexperienced maintenance programmers looking at my code and asking questions that any coder with a clue would instinctually know. Take for example this function:


My Very Own math.round()

by in Feature Articles on

Brad has actually discovered what appears to be the second most useless Java class written. Yes, it's almost impossible to follow and replaceable with a single line ... but dang ... it's just too hard to top the ObjectWrapper.


Covering All Cases ... and then some

by in Feature Articles on

Ben Murphy found a developer who liked to cover all of his bases ... then cover the dug-out ... then the bench. If you think this method to convert input (from 33 to 0.33) is a bit superflous, you should see data validation.


java.lang.HowBigIsMyCallStackException

by in Feature Articles on

A little while back, we got to see how fun recursive sorting algorithms cam be. But that's not the only place where we can have funn + funn-1. How about ... exception handling in java!


One way to handle Proper Case

by in Feature Articles on

Maybe I'm shooting at an unfair target here, but Dave sent in this from Crystal Reports. Now if you think BASIC code can get ugly ... well, just take a look at this ...

if {crGetPassportDetails;1.Name} = 'SOUTH AFRICA' then "Visitors to " + 'South Africa' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'PUERTO RICO' then "Visitors to " + 'Puerto Rico' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'UNITED ARAB EMIRATES' then "Visitors to " + 'United Arab Emirates' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'CAYMAN ISLANDS' then "Visitors to " + 'Cayman Islands' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'HONG KONG' then "Visitors to " + 'Hong Kong' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'RUSSIA FED EUROPE' then "Visitors to " + 'Russia Fed Europe' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'CZECH REPUBLIC' then "Visitors to " + 'Czech Republic' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'COSTA RICA' then "Visitors to " + 'Costa Rica' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'NEW ZEALAND' then "Visitors to " + 'New Zealand' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'ANTIGUA AND BARBUDA' then "Visitors to " + 'Antigua and Barbuda' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else if {crGetPassportDetails;1.Name} = 'ST LUCIA' then "Visitors to " + 'St Lucia' + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."

else "Visitors to " + Mid ({crGetPassportDetails;1.Name},1,1 ) + LowerCase(mid({crGetPassportDetails;1.Name},2,length({crGetPassportDetails;1.Name}))) + " require a full passport which must be valid for " + {@MinMonths} + " months after departure from this country."


There's always more than one way to an index ...

by in Feature Articles on

... just as Thomas Magle Brodersen found in some production code.


A Tale of Two Comments

by in Feature Articles on

Being as uncultured as I am, I'm completely to come up with some witty way to tie-in today's post with the Charles Dickens' classic. To my credit though, I did make it through the ultra-condensed version and I watched LOTR:The Two Towers (which I'm sure is a pretty similar story).

Anyway ... Ryan discovered, something we can definately file under "least usefull comments" ... 


Welcome to the Real World

by in Feature Articles on

I most of us felt (or, will feel) let down after getting our first job of college. Going from the world of "assume there is an unlimited budget, now ..." to "change the text of the error message generated by ..." makes you feel as if your hard-earned Computer Science degree was as useful as Mordar, your almost-equally hard-earned level 28 half-elf wizard. Of course, this is nothing compared to what Michael Jervis must have felt ...

Shortly after graduating, I started with a small web shop that had just been acquired by a big Tin shifter to start up their services offering. My new boss had written his own ASP editor that he wanted me to use in preference of any decent mature third party code editors, or visual Interdev. Last time I looked (a few years back) it was still available, shame it appears to have disappeared. It was a true master piece of an editor. It was impossible to indent code, as the TAB key in the main text area (no syntax highlighting of course) was forcibly bound to change control focus. The choice of colour was "interesting" and it had many other amazing features. But that was just the start of my boss' genius.


Looking to the Tech Leader

by in Feature Articles on

Jeff Davis sent me this advertisement the other day, and I thought it'd be a perfect compliment to a post. But now every time I look at it, I keep seeing something new. So, here it is, your week-end post.


Thank Goodness there's "Option Strict Off"

by in Feature Articles on

Without Option Strict Off, the compiler wouldn't even let you try to stuff three different return values into a boolean value, as Jeff Atwood's colleague likes to do ...


Stand Back, I've got Hexidecimal

by in Feature Articles on

First, minor off-topic here, I'm thinking it'd be a fun idea to kind of expand on the site and community here and try to offer some other more general content in different feeds. I mean, programming can't possibly be the only thing that makes you ask WTF, right? For example, Tim Cartwright pointed me to this article ... and I made an interesting observation today when looking to buy phones on Amazon. Both elicited a similar response for me ... perhaps they will for you. Thoughts? Ideas? Suggestions? Submissions? Just send em along and I'll look to start up a new feed.

With that said, some of the commenters on Monday's URLEncoder blamed the language for allowing such an attrocity. I think after seeing Bob Gateaux's discovery from a C++ project he inherited, we can put the language-is-to-blame theory to rest. Note the elite use of hexidecimal.


Some Good VB, for a change

by in Feature Articles on

In fact, this VB Code is so good, that it's bad (which is how it ended up here, afterall). You see, James' colleague understood that hard coding things is bad. He even resisted coding "0", even though it is only used once, and even though it is used a few lines below the constant ... now that's good.


Worst. Reimplementation. Ever.

by in Feature Articles on
Sorry for the physically long post today, and on that note, for the cliched post title. But I think it's justified. You see, today's post is not just a WTF, it's a WTF2. We not only have the built-in method ignored, but the reimplementation (is that even a word?) is, I believe, the worst possible way to convert an 8-bit integer into a 2-digit hexidecimal code.

Jørn Aakre was tasked to fix the entire project and brought it down from 2mb of source code to 80k and ~100% full-time CPU utilization to <1%. And, naturally, Jørn was paid a fair 200-400% less than the original consultants who developed it.

#define 1 as 2

by in Feature Articles on

What better way to give unsuspecting developers a challenge than to redefine some straightforward numeric constants to completely arbitrary values? How about hiding the #defines in different header files and randomly flipping between the using the constant (CTR_DTE_DATA_RATE_300) and its value (5) throughout the code. Don't you wish you were Carl Kritzinger?


Some more UnintelliSense&#174;

by in Feature Articles on

I don't think today's post is an example of anyone's egregious incompetence, but it still made me say you-know-what. Now, as I mentioned before, I think IntellSense is the greatest productivity gain since the mouse. But, I'm not sure it's helping Eric Nesser so much ...



The not-so-efficient StringBuilder

by in Feature Articles on

The .NET developers out there have likely heard that using a StringBuilder is a much better practice than string concatenation. Something about strings being immutable and creating new strings in memory for every concatenation. But, I'm not sure that this (as found by Andrey Shchekin) is what they had in mind ...