Recent CodeSOD

Code Snippet Of the Day (CodeSOD) features interesting and usually incorrect code snippets taken from actual production code in a commercial and/or open source software projects.

Feb 2011

Functionally Functional

by in CodeSOD on

Microsoft's Active Server Pages (ASP) technology (or, Classic ASP as it's called these days) was designed to an easy way to build web applications: just code some HTML and sprinkle some VBScript between <'% ... %> blocks. It was (and, for the most part, still can be) a decent, simple tool for building simple things.

Of course, there's one big problem with simple tools: they're simple, and certain developers are too smart for simple. And that brings us to Catherine P, who's found herself maintaining a sprawling mess of a Classic ASP system that should have been retired years ago. Of the many "innovative and unique" patterns introduced by the original developer is "limiting the amount of JavaScript sent to the browser." As to how is this wizardy is accomplished... there is code like this is in the header of each page.


Number 15

by in CodeSOD on

With the addition of Josh M., he was now officially the 15th developer in the past 7 years to work on the small company’s HUGE PHP/MySQL web app.

The whole site seemed to be a WTF, and yet one part stuck out like a sore WTF-thumb. It was the 'static text' table.


Adding a Column

by in CodeSOD on

"Generally speaking," Brian H writes, "I'm a pretty good judge of how challenging a feature will be to implement. Take add column X to report Y for example: first ensure that data is available, then modify the report's query, and then finally tweak the report layout. Easy peasy, and worse case, you'll have to battle with how to fit everything on a page."

"And then of course there are those times where I'm completely wrong. The following is but a glimpse into the pain that was needed to add column X to report Y."


The Marshal

by in CodeSOD on

When Eli accepted a position nicknamed The Marshal, he knew he’d be in for a challenge. For many years, the company’s culture was dominated by cowboy coders and a frontiersmen attitude of just get’er done. Though many of the code-slingers had long since retired, the spirit of the Wild West still remained.

Strewn across the vast corporate expanse were dozens and dozens of ghost applications that weren’t on any IT Systems map, yet were still used by various business units. Some were small, living on an old workstation under a desk, while others were large, forgotten systems that once were fertile pastures of development.


Squeaky-Clean HTML

by in CodeSOD on

Sami's company developed Yet Another Proprietary CMS and, like many home-grown systems, they've had to reinvent many wheels.

Naturally, their wheels aren't perfectly circular... and often times, they won't even fit into the most liberal definition of "round". But to their credit, the developers do try their best to be as thorough as possible. And they take cleaning HTML very seriously.


Annual Y2K

by in CodeSOD on

Those of us who lived through Y2K remember that, after all was said and done, it was little more than an inconvenience. Fix a couple of reports displaying “19100” here and correct some validation logic there. Although Sherman wasn’t there to experience all of the Y2K fun, as a maintenance programmer, he has had the pleasure of experiencing exactly what it was like, each and every year.

In fact, his very first assignment was to fix a Y2.007K bug in an application developed the previous year: the original developer simply hard-coded 2006 as the year. And it wasn’t the only Y2.007 bug.


Sturdy Switch

by in CodeSOD on

"Without a web framework," William I. writes, "developing AJAX-based code can be a bit tricky. Mostly, because of the way X (XmlHttpRequest) deals with A (Asynchronous): you have to 'listen' to the onreadystatechange and act when the readyState is 4."

"Of course, most folks deal with this using a simple if (readyState == 4) statement. Some coders... well... they do this."