Recent Articles

Nov 2005

Irregular Expressions

by in Feature Articles on

It's a pretty common occurrence to see a programmer completely disregard regular expressions, instead implementing his own validating code. A handful of the Do-It-Your-Selfers will even implement their own substring searching algorithm with all sorts of varieties of loops and the like. David Conrad's colleague managed to not only skip the built-in parseFloat method, but use regular expressions, an array, and a loop to do so ...


Rewarded with Commenting

by in Feature Articles on

As a reward for finishing up development on a project a couple weeks ahead of schedule, Jon was tasked with taking a look at some of the other systems his company develops to document and comment on the architecture and code. One system he came across had a unique way of managing database communications: each class was responsible for generating a SQL Script, "setting" it, and passing it to an execute function, which would then "fix" the script and execute it. You might be surprised how difficult it is to speculate and professionally explain the reason behind this ...


Internationalexemelization

by in Feature Articles on

There are some developers out there who believe that XML is the greatest "innovation" in computer science since electricity. Believing that, apparently, all data and communication are best represented as strings with angle-brackets, they'll go to great strides to ensure that this "technology" is applied liberally throughout systems they build. Undeterred by the inherent constraints of a data interchange format and its related transforms, they'll make sure that XML is not only the driving force behind their projects, but their raison d'être.

Joe works with one such a developer, and presents us i18n.xsl, the end result of his colleague's six straight days of work trying to get his fully-XSL solution to properly display HTML characters.


Your $2000 Function, Rebilled

by in Feature Articles on

I've often wondered what kind of code you get when you pay a consultant $250 an hour. I figured it would be nothing short of awe-inspiring. And now that I've actually seen (thanks Will Nesbitt) code produced by a two-grand-a-day consultant from IBM, I can say that it is certainly is awe-inspiring ... just not in the way I had hoped.


Pre-mapture Optimization

by in Feature Articles on

Eljay's coworker is afflicted with the rather embarrassing condition of premature optimization. Every few blocks of code, he'll start to panic, worrying that his code isn't fast enough, that he's wasting too many resources, that he's just not doing it perfect. As is often the case, this condition creates some rather entertaining (though often buggy and less efficient) code. The FastMap demonstrates this, employing the superstitious belief that a HashMap with less than five values is just too slow ...


Buggy.NET

by in Feature Articles on

Jon Colomis works with the (self-proclaimed) world's best coder, who's qualifications include an honours degree from a first-class UK university AND a *solid* semester of real-world experience. Being the C++ fanatic that he was, Jon's colleague had always refused to do anything in "the heap of bugs that is .NET," insisting that his "bug-free" C++ was far superior. When a client required that C# be used on a new project, the world's best coder finally agreed to give it a shot.

After a few hours of trying it, he demanded that his portion of the project be coded in C++. "Microsoft couldn't even spell QA," he quipped, "writing to a stupid property overflows the stack!" When Jon pointed out his mistake, the word's best coder scoffed, claiming that "this crap would never happen in C++" ...


Better Off TODO

by in Feature Articles on

Peter S. noticed that his company's flagship product, a parts management system, had a lot of advertised "details" that just didn't seem to work. Being the motivated guy that he is, Pete took it upon himself to fix these, starting with a non-functional search for all container parts given a particular part. Upon looking at the code, he decided that maybe it was just better off left TODO ...


Pop-up Potpourri: Episode IV

by in Pop-up Potpourri on

It's that time again! And in case you missed it, here's episode III: Pop-up Potpourri: Aracde Edition.


William Highfield was installing an application and was confronted with this dialog box that was, apparently, referring to the other English (United States) language.


The 2,000 Pound Question

by in Feature Articles on

David was modifying a report produced by one of his company's applications and disabled rounding for debugging purposes. He thought it was a bit strange that the Tons field overflowed with itsy-bitsy fractions (such as 22.500002480200558937997962267231), especially considering the incoming pounds data was in large whole numbers (such as 45000). Looking at the PoundsToTons() function, David figured that the original code must have gotten a drastically different answer when asking How many pounds are in a ton? ...


Don't Worry, Everything Should Be Clear

by in Feature Articles on

Andy O. was tasked with porting a Pascal-based system running inside of an Atari-emulator to a more modern platform. Being neither a Pascal- or Atari-wiz, Andy was a bit weary of the project. "Don't worry," the original programmer reassured him, "everything should be clear." Andy's concern was assuaged for a little while, until he looked at the global declarations of the program ...


There's More Than One Way To Neg. A Num.

by in Feature Articles on

Programmers have an innate desire to reinvent, over-engineer, and over-complicate things. I've always believed it's a result of the "fun" gap between what's needed (a simple HTML form with a generic FormMail.asp script) and what's challenging (a 12-layer Service Oriented Architecture involving a XML-configurable wrappers for every framework class, HtmlFormConfigurationHandlerProviders, FormEmailManagers, a FormEmailManagerFactory, a FormEmailManagerFactoryFactory, and so on).

The good programmer will fight his urge to build The Greatest System Ever Built, instead providing a more modest solution. Dwayne's colleague, on the other hand, will make sure that nothing is as simple as multiplying by -1 ... Dwayne


The JavaScript Search Engine

by in Feature Articles on

You knew that it would only be a matter of time before some one would take our favorite scripting language, JavaScript, and try to build one of the most complex creations in computer science, a search engine. Andrew Taylor was browsing a certain company's website and noticed that their search function was wholly useless, but seemed to return results incredibly quickly, without even reshing the page. Curious as to what this might be, Andrew did a quick View Source and uncovered the JavaScript Search Engine ...


A Careful Balancing Act

by in Feature Articles on

There's not much more I can add to today's story, so let me turn it over to Alex Villacis Lasso ...

I once worked as a junior programmer in a once important bank in Ecuador, South America (which bank, I won't say, but its name starts with an "F"). This bank had an IT department in which MS VisualBasic 5 was the dominant tool, with some mainframes thrown in and running programs written in COBOL, RPG, and a few other exotic languages. While working there, I was assigned the following task: take an existing program (whose purpose I will explain below) and modify it to accept a new file format. When I finished studying the program, my jaw had dropped to the floor...


Everything ... and I mean Everything

by in Feature Articles on

Today's code is an example of a fairly common pattern I see: a SQL query generator from some middleware generates an absurdly long "IN" predicate that includes the identifier from each row in the table. I'm not quite sure how one could manage to build a system that generates such a query, but I've always let these submissions slide anyway; they just didn't seem to be "enough." What makes Tim Hughes' find so impressive is that the "crack" C++ developers on his team were perfectly aware of how bad of an idea it is to make such absurdly long "IN" lists. Instead, they made sure to "OR" together their really long "IN" lists together. They even made sure that the WHERE clause wasn't too long, instead performing a "UNION" on multiple queries. The one part that they were having trouble with was getting their query to run fast, though ...


Not Trusting a For-Loop?

by in Feature Articles on

Matthias L was browsing through some code from a (publicly available) web application that his company developed and came across this rather curious bit of code. It's a JavaScript function that runs in the HTML document's OnLoad() event. Matthias stared at it for a little while, and its existence remained a complete mystery. He sent it to me, so I stared at it for a little while. I've got nothing. Any brave "code defenders" want to take a stab at this?


Back to Hotel Hell

by in Feature Articles on

Alex is off vacationing in Detroit today (who goes there on vacation?), so let's take a look back at a WTF classic. I know this one was a favorite around our office, so if you missed out the first time, I'm sure you will enjoy.  On top of that, today you get a two for one, lets take a look at a summary from The Hotel (reservation system) From Hell and the The Hotel (reservation system) From Hell, Continued.

Over the past few months, we've all seen some some rather ... unique ... ways of doing various things, programming and otherwise. But today is different. Today, we will see what only Nikolay Simeonov and a few other brave souls have seen. We will see the abomination whose mere thought would send many programmers into the accounting profession. Yes, today's post will contain a glimpse of the reservation system from the Styx (the river, not everyone's favorite 80's band) Motel itself ...


Truth Is How You Define It

by in Feature Articles on

Miguel Arguelles' company recently hired a fresh graduate with a fairly good resume and high academic marks. One day, while debugging some of his colleague's code, Miguel noticed that most of the conditional expressions were inelegantly formed with redundant Booleans, abuse of operators, and so on.


A Truly ID-iotic Design

by in Feature Articles on

There are those who believe that each and every table in a relational database must have a "uniquifier" Primary Key (IDENTITY, SEQUENCE, GUID, and so on) and there are those who actually know how to design a relational database. As Dave points out, the trouble comes when the former group is actually allowed to design databases.

Day one in a new contract, with a large multi-national bank, and a little bit of digging in the database for a business-critical application uncovered the wonderful table tDayOfMonth:


Greater Than or Equal to the Minimum

by in Feature Articles on

Continuing with this week's series of "punch line code" samples, I wanted to share with you this small bit of T-SQL that Tracy McKibben uncovered. It's from the same codebase that we all peeked into a number of weeks back. Anyway, if you needed a command that would delete all rows from a specific table, you'd probably do something like this:


Squishin' de Bugs

by in Feature Articles on

Josh is the code reviewer on a fairly-large, Java-based message routing system. At one of his reviews, a coworker submitted some code that logged events like this:


Self-Documenting Comments

by in Feature Articles on

In yesterday's post (Doing What You Say, Saying What You Do), we all learned how important it is to be explicit when naming functions; preferably, one should encapsulate the entire function's logic into that function's name. Although I didn't cover commenting in yesterday's post, the same rule should apply: be as explicit as possible. The ideal comments are free of any non-programming languages (English, Dutch, etc) and should be as verbatim to the code as possible. Nick F demonstrates this perfectly with code from (what I would imagine is) the set_actionType_to_cont_or_end_depending_on_whether_hasSiblings_is_true_or_false() function ...