Recent Articles

Jan 2007

Gaming Ground

by in Representative Line on

I generally don't publish code from the videogames because I don't believe that code quality is as important in that industry. Short of the occasional patch, once the product is shipped, it's done; there's no ten-year lifespan to worry about.

That said, it's still important to maintain some level of quality. After all, there are several people that need to work on the game, if only during its brief development lifecycle. When Brian P saw the last Representative Line article, he knew that it was an ideal place to share this following line. It's from a title that has made it through the manufacturer's QA process and has just been released in Europe, the US and Japan ...


Paid by the Line

by in CodeSOD on

Frank is a contractor. His company has been brought in to refactor some back-end web services that were all developed by a single person, "Nicholas," over the course of a couple of years.

From the front lines,

Having looked at it, we've decided that a complete rewrite is the only solution. Here's just one example of what can only be called "paid by the line" programming.


The Art of the Cold Call

by in Feature Articles on
 Cold calling ain't easy. First, you have to find the right person (the "Decision Maker") at an organization to talk to. Then, you have to briefly convince the Decision Maker (who is hardened to such Cold Calls) why she should even listen to you. And finally, you have to briefly give your sales pitch and hope that the Decision Maker is half-paying attention. Any mistake along the way runs the risk of not only losing the potential client, but tarnishing the brand and its reputation amongst the Decision Maker's peers, who generally are Decision Makers as well.

That said, it's pretty impressive to see someone strike out on all three aspects of the cold call. Shawn Miller experienced this first hand when he got a call from I---, an account executive at PCMall. With I---'s broken English, it took Shawn a little while to figure out why he was being called in the first place. I--- wanted Shawn to setup an account with PCMall to purchase hardware and software.

After fifteen minutes of politely trying to explain that he wasn't the Decision Maker and that now was a very bad time to call, Shawn had no choice but to had to hang up on I---. Several minutes later, the following email popped-up in Shawn's inbox:


Reinventing the Web

by in CodeSOD on

Our friend David had some time on his hands and a great idea for a web app: that's the recipe for success. Wanting to concentrate on the PHP back-end, he brought in a friend to develop the AJAX front-end.

Unfortunately, things started to get thorny when it came to connecting the two. The browser-side demo looked great but all the forms were submitting data through GET instead of POST. This was a major problem for the application, so David got a shovel and dug into the "AJAX".


The Contractor's Note

by in Feature Articles on

The easiest and most popular place for Incompetents to hide is within the ranks of professional contractors. It's an easy job. Generally, the first few weeks are slow; everyone is so busy (hence the need for a contractor in the first place) that they have no time to train someone new. The next few weeks are equally slow, as only small and easy-to-understand tasks are dolled out. By the time anyone discovers the gross incompetence (if it's discovered at all), there's only a week or two left in the contract and they just let slide. And then The Incompetent moves on to his next contact.

Seasoned Incompetents are excellent at what they do: they look great on paper, know how to talk the talk, and definitely know how to avoid the walk. Mark B's company was fleeced by such an Incompetent. But this contractor, however, made one big mistake: he went to a smaller shop that actually needed and expected someone to help them out.


Well, Open it Anyway

by in CodeSOD on

Lemma #1: Email is important. Corollary #1: It is therefore bad when email stops working. Conclusion: That's why one of the project managers was frantic.

That's who went and got Anne when she came into work. Going down the standard checklist: the server was up, sendmail was alive, but curiously /var (of /var/spool/mail fame) was 100% full. A quick perusal of that directory revealed a multi-gigabyte message sitting in /var/spool/clientmqueue; but why was it there?


But It Worked in the Demo

by in CodeSOD on

We've all been there: all of your test cases worked the night before but when it comes time to run the demo you realize you missed something. In college, I had to write Sub Hunter in assembly and those pesky submarines kept launching missiles after I depth charged them back to hell. The TA didn't notice either. It wasn't until later that I learned about the magic of peer review. Not that fewer bugs sneak across the unit test border, you just feel better because someone else missed the problem too.

Luckily for Christian's friends, he's on patrol. When one of his friends ended up on a randomly assigned project team, Christian took a look at some of the code. Apparently "Karl", the person in charge of the authentication module, wasn't too good at taking criticism as long as the unit test passed.


Disjoint Twins

by in Feature Articles on

I'd imagine that there's a lot involved with bringing a new person into this world. No, no -- I don't mean that part, I mean the whole paperwork side of things. There's Social Security to set up, a .name domain to register, birth certificate, insurance -- especially insurance. With all those people feigning pregnancy and labor just to get a stay at the hospital and a complimentary "It's a Boy!" balloon, insurers need to be extra certain that childbirth claim resulted in a real child.

As the recent father of twin babies, Philip B. was relieved to learn that his employer's benefit provider, Sun Life Canada, made the insurance process really simple. Adding the little ones on the plan required no more than a phone call to provide birth dates, names, and that sort of thing. All seemed so easy, until the customer service rep realized what Philip was trying to do: "I'm sorry sir, but we need a different birth date for each of your kids."


Catch and Release

by in CodeSOD on

One thing that is quite clear is that many of the people that write in are called Don. The corollary is that if you want to see less bad code, change your name. What isn't clear (to me, from the submission) is what Don's company does.

Whatever they do, they send out a lot of template-based email. Even better, it's all environmentally friendly: they have a catch and release program. In case you'd like to start a similar program, here's some exceptional sample code written in C#.


Trust Me, I'm A Doctor

by in Feature Articles on

K.G. has been working in Information Technology for twenty-five years. He's built systems in COBOL, lead teams of C++ developers, and designed complex applications in ASP.NET. These days, K.G. finds himself taking it easy and picking up the odd freelance job here and the interesting-sounding contract job there. But despite this wealth of knowledge and experience, there is one individual whose expertise transcends it all: The Medical Specialist.

A Medical Specialist is like a doctor's doctor. They have several more years of formal training, often a PhD to go with their MD, and are the people that regular doctors ("Gennies," in specialist-speak) go to when they need advice. K.G. had never directly worked with one before and didn't realize that Medical Specialists are endued with expertise in all fields of study, including software development. So when a Medical Specialist (specifically, an Endocrinologist) approached him to help "clean up" and commercialize some software, K.G. agreed. It sounded like a fun project.


Configuration Made Easy

by in CodeSOD on

While Dan doesn't work for them, he has had occasion to see their source code. Who are they? Only the biggest and best in all of Europe when it comes to document management!

But having thousands of customers using your .Net product isn't enough. No, their biggest asset is customization. Not just for the high-rollers, when a customer --- any customer --- asks for even the slightest change, they listen. And how do they do it? Let's take a look!


The Sorcerer's Apprentice

by in Feature Articles on

I don't need The Sorcerer's help, Rod Taylor scoffed to himself, I've watched him debug time and time again; it doesn't look that hard!

In those days, debugging mainframe applications was not a trivial task. There were no such things as error logs, trace listeners, or any of those other luxuries that modern software developers have become accustomed to. All one had was the Core Dump, a byte-for-byte copy of the system memory, and getting that Core Dump wasn't easy. That's why only the gray-bearded gurus like The Sorcerer were called upon for such a task.


Online Offline

by in CodeSOD on

Ben S. submitted the following piece of SQL. It's only a few lines of code, but both the variable names and values are a bit... curious.

I can only imagine what context this code appeared in, or what the author was trying to achieve. What do you think?


The Big Red Button

by in Feature Articles on

Take-Your-Child-To-Work Day never made much sense to me. Unless you're someone cool like Tony Hawk or Batman, showing kids the reality of the workplace just seems outright cruel. Cubicles, meetings, TPS reports -- I mean really, while you're at it, why not just crush all of their hopes and dreams and tell them that Santa Claus died in a mid-air collision with the Tooth Fairy, the Easter Bunny was run over while trying to save the world's last candy factory, and that there would never be any birthday parties ever again. It's practically the same thing.

Apparently, not everyone shares my point of view. At least one day each year, I notice kids all over the place, from standing behind the counter at the jeweler's to playing in a corner of the executive's office. Some organizations, such as Robert R's, even formalize the whole thing, giving presentations about what mommy's employer does and taking the sons and daughters on a guided tour of the workplace. Thinking about the workplace from a child's perspective, the only places that might actually be fun to visit would be the elevators, the vending machines, and possibly the data center. Robert's employer must have agreed, as they made sure to include all of those places and many more in their annual children's tour of the facility.


Breaking Out of the Box

by in CodeSOD on

Today, we've got a triple-header of stuff that's probably too short to post on its own. The theme, briefly: loops. (Because who doesn't love loops? I know I do!)

Where Mike works, they reward people for thinking outside of the box. He didn't find this code (a coworker did) but he did give it a gold star for breaking the mold.


Round and Round

by in CodeSOD on

One of our agents has a problem. For years, floating-point math has been too complicated. Remember the good old days? You used to be able to type var=INT(var+0.5) without black-box functions getting in the way. These glory days are long past.

In fact, the reason the IEEE was created was to make floating-point math miserable, especially when it comes to rounding. It is in this new world that Smith works, attempting to round to an arbitrary number of digits. However, when he puts 39.995 into his function, it returns 39.99 instead of 40.00. Other inputs produce the expected output, e.g. 11.995 produces 12.00. Can you solve the mystery?


Chocolate Covered SQL

by in Pop-up Potpourri on

Matt M, there is no dialog there. You see nothing ...


Time to Deprecate

by in CodeSOD on

It's time to get rid of C. The language itself is over 35 years old and the standard library is insanely complex. There's even a header file called complex.h, if you need proof. The "stdlib" has even infected pure languages, like Perl.

James' coworker realizes this and is fighting back! As part of his protest against the functions in time.h he's found new and interesting ways to manipulate time in Perl.


Ability to Bend Space-Time a Must

by in Feature Articles on

A project manager at Martin's company approached him for help with some survey software. He'd written and maintained similar software before, so it wasn't a big deal.

Martin's job duties as a web developer included some murkily-defined responsibilities including "Other Duties as Required." With the PM's request, Martin learned that "Other Duties" actually means either clairvoyance or independence from space-time.


RubyOnRegexp

by in CodeSOD on

I should preface this by saying that I like Ruby: it allows you to express both powerfully and tersely. But to be trite, with great power... well, you know the rest. As for RubyOnRails: I haven't gotten around to using it but a lot of people have and like it very much. Being Open Source, there are supposed to be a lot of people watching. Fabian is one of those people.

He sends us the following single like of source code, broken into multiple lines for your viewing pleasure. Watch, in amazement, as we dissect a RegexpInRuby.


The Complicator's Gloves

by in Feature Articles on

Good software is constantly under attack on several fronts. First, there are The Amateurs who somehow manage to land that hefty contract despite having only finished "Programming for Dummies" the night before. Then there are The Career Amateurs who, having found success after that first contract (read: taking the client's money and not being sued for developing a useless product), actually manage to make a career out of repeating that experience. And then there are The Complicators, the side that tempts the best of us to join their ranks, even if only for project or two.

There are some so deeply embedded within The Complicators, that they've acquired a sort of sixth-sense: the ability to find meta-problems ("a problem with the process of creating a solution for the actual problem") in virtually any solution. As we've all seen, the systems that these developers create often end up as a barely functional application comprised of a Matryoshka-doll-like nesting of problems and solutions. Given the chance to solve problems outside of Information Technology, I've often wondered how The Complicators might respond. Fortunately, Mike has given us that opportunity ...


If At First You Don't Succeed

by in CodeSOD on

While working with someone else's "utility class," David decided to have a little fun and turn on compiler warnings. It turns out that the compiler is actually sort of good at catching weird abuses in Java.

 

As he put it,
I turned on some additional compiler warnings, including one to warn about undocumented empty blocks, and it complained about the catch block below. Catching and swallowing exceptions is all too common on this project (as are the completely useless javadoc comments that don't actually document anything), but this is the first time I've seen someone...
Actually, why don't I just show you?

RAIDing Disks

by in Feature Articles on

"Wait a sec," Ove N. said, "your current network support guy charges a monthly retainer and hourly fees? You know, it's supposed to be one or the other; not both."

Ove's client-to-be looked a bit dismayed, "that's what we thought; but he said that this is just how it's done!"


String Optimizations in Java

by in CodeSOD on

In many languages, Strings are not just the "arrays of characters" that our Introduction to Programming professor told us about. More often than not, they're immutable and sometimes magical: you can't really combine them, you can only conjure new ones. Since creating a new object is usually costly, it's not optimal to use a java.lang.String if you're going to do lots of concatenations.

Someone Oscar works with realized this. As he puts it, "You cannot accuse this developer of being oblivious to the performance advantage of using StringBuffer."


Validating Nothing

by in CodeSOD on

At Fischer's company, they work with a lot of consultants. Many of these consultants, not worth their salt, are sent down the river when their contracts end. Once in a blue moon, however, a shining example of what it means to be a developer comes down the pipe. These mighty few are given offers to become real employees.

As he puts it,

Normally, you'd think this could be a positive thing whereby we could listen to all the consultant's battle stories and learn from other people's mistakes without making them ourselves. Well apparently we're going to be learning from our own mistake for many years. Here's some fresh code from by our newly hired, full-time staff member.

Interview by Proxy

by in Tales from the Interview on

I Do Models
From Sam F...

It was 1992 and I was fresh out of school trying to get a job. My Political Science degree wasn't doing anything for me, so I decided to try out a new field: information technology. I eventually landed an interview that went surprisingly well until we got to the technical part ...


The Long Road to Clean Up

by in CodeSOD on

One of Joe J.'s first tasks at his new job was to "clean up" some existing code. We always hope for the best in these situations, but since the code has ended up here, you can tell where this story is going.

The .NET framework has a handy getFileName method, which returns only the file name from a complete path. Since library methods aren't to be trusted, Joe's predecessor decided to use the following routine instead.


It's CAD-tastic!

by in Feature Articles on

"Wait a sec," an Apple Computer rep said, halting right in the middle of his sales presentation, "this is actually a functional CAD application? And you developed it all on your own? That's incredible! You really need to market and sell this thing."

The Professor had never really thought about it before, but compared to all the commercially available CAD software, his FORTRAN-based program developed was pretty impressive. Not only did it have all sorts of whiz-bang features, its GUI was very intuitive (not an easy task for something as difficult to navigate as 3D drawings) and it was able to run perfectly fine without the need for one of those several-thousand dollar, fancy-schmancy 8-MB video cards. After scouting around for a few months, the professor finally found a company with a "proven track record" and "expertise" in taking programs like his and bringing them to market. They were blown away by The Processor's application and proposed a simple, three-step plan that would make everyone rich: 1) Tweak & Clean-Up; 2) Brand and Market; and, of course, 3) Profit. How anything go wrong with that?


Primitive Wrapping and Unwrapping

by in CodeSOD on

Daniel Rivera writes with a short but effective snippet. The company he works for purchased a JAVA "Application" developed offshore. The decision to purchase this software was made based solely on a PowerPoint demo given to the CEO.

Now in this particular JAVA example, a method called someMethod ( Integer someInt ) needs to be called with a given hard-coded primitive value like 0. One way of calling someMethod might look like this:


A Secure and Well-Ventilated Location

by in Feature Articles on

A major part of Don Q's job is to fly out to construction sites and setup their computer network. Weeks before doing this, Don meets with the project manager to make sure that every one knows what needs to be done and how to do it. It's up to the project manager to make sure that the workstations, server, cabling, power, etc. are all in place before Don arrives, and Don makes sure to give concise but not insultingly-simple instructions on how to accomplish that. One of these tasks is simply: install the server in a secure and well-ventilated location.

Don had dolled out that task to construction project managers countless times, and they had always complied without issue: the server was installed in a secure and well-ventilated location. After all, where else would one put a $15,000+ computer running $100,000+ software to manage a $50,000,000+ construction project? When Don arrived at one particular location to setup the network, he discovered that the project manager had a slightly different interpretation: The Men's Room.


Little Black Book

by in CodeSOD on

It wasn't that Graham's company lost an employee, it's that they gained a consultant. As an employee, this person excelled at many things, naming functions not the least of these.

As Graham recalls: he was a funny guy - had a real thing about women's names, and always used them for function calls whenever possible. Here's an example which ... stuck in my mind because of that sole bug report comment(!) in the middle.


The Fudge Factory

by in Feature Articles on

One of the most important aspects of being a hosting company is keeping track of bandwidth usage. As a lowly UNIX admin, Jay never really knew how they did that until it had broken a year back. It turned out that bandwidth monitoring was done with a creaky, end-of-life Sun system that sat near the routers and constantly polled them, adding up the bandwidth usage, generating log files, and then mailing those up the chain to the financial people. It had been set up so long ago that the tech that did it became a senior tech, and then a leading tech, and then a chief tech, and finally, a CTO at another firm.

Obviously the tech hadn't touched the bandwidth watcher after the "senior" promotion, so the boat had been quietly floating without a captain for quite some time. Fortunately, Jay was able to go in with his mining helmet and hack at it until it worked again. But there was just one problem: the logs had lost a full day of data.


The Data Cleanup

by in CodeSOD on

Ralph B. submitted today's scary code snippet, found in a script used for "cleaning up" data from a widely used and well-respected data source for use in another widely used and well-respected data source.

It's not so amazing that this code does work, but there has to be a better way to do this. I'm not a SQL guy, but maybe another script is needed to clean up the clean up script...  


Announcement: New Website Software

by in Feature Articles on

As you may have already noticed, I've changed the software that runs The Daily WTF. Before today, the entire site was powered by a hacked-up version of Community Server Forums. It worked, just not so well for how The Daily WTF runs.

The new software was written by yours truly and takes into account a lot of the feedback I’ve gotten over the years:

  • The Home Page is way too big
  • The Article Page should not display the Comments
  • There’s no way to see an entire Series (such as the Pop-up Potpourri)
  • Etc...

A Show of Hands

by in Feature Articles on

Development Manager. Yeah, it was a Pointy-Haired-Boss title, but Jamie was ready for that. He had put in his years as a developer and knew it was the right time to move on to management. Besides, the team he'd be managing was fairly small, and he could always jump in to help out with some coding if needed. The offer was just right and, like that, Jamie became a manager.

The company was a business directory publisher and, for the past quarter century, had outsourced the majority of its software development to an IT consulting firm. And by "consulting firm," I mean a one-man company employing a single consultant. And by "consultant" I mean, a guy whose twenty-five years of experience came from his one and only client, the directory publisher. This consultant was who Jamie and his development team would be competing with to provide client departments (Accounting, Editorial, etc) with applications.


Making Time for UNIX

by in CodeSOD on

David works for a company that writes applications that care about when things happen. Needing a bit more time to work on other things in-house, they outsourced some module development to China.

In his own words,

They helped us to develop some modules, and my boss asked me to review one of them. It seemed to be working fine, so I decided to look into source codes. I shouldn't have do it.


The Tale of a Spam

by in Feature Articles on

As hard as it may be to believe, there are actually quite a few people out there who like spam. There's the Lonely Type, sitting at home on a dateless Saturday night just waiting to hear "You've Got Mail!" Then there's the type who just feel good inside knowing that someone hooked them up with an awesome deal on \/1@Gr@ and a H0/\/\3 M0rTgaG3. And then there's the Hormel folks, whose 2006 Annual Report stated that 33% of SPAM purchases were for "gag and joke purposes specifically related to unsolicited email." But Adam Golebiowski isn't in this crowd; like most of us, he doesn't like spam at all.

Every once in a while, a spam message will slip past Adam's greylist/SpamAssassin filter and prompt him to respond with a simple click of the Delete button. A recent message, however, piqued his interest. It was from "an old time frend from hig school," who was writing to tell him how "many riches [he] had become" after "findouting about the gratest webs," which sold a database of "all the infos to become a business success." Tempted by potential of infinite wealth and a much needed break from a late night of studying, Adam clicked through to the website  -- err, I mean -- the "webs."


Finding Random Rows

by in CodeSOD on

We all make rookie mistakes, especially as rookies. In an act of humility, DJ sent us some PHP she wrote at the tender age of 19.

From the submission,

I recently ran across some code I wrote on my first project for a new company I'd just started working for. Part of the site required I show some content picked at random from a database. Since I'd only been doing PHP for about 6 months I was blissfully unaware of the array_rand function so I wrote this instead.

Security by Insanity

by in Feature Articles on

We've all probably experienced Security by Obscurity. Most of us have now seen Security by Oblivity. Kurt G. is the only one I know who has come face-to-face with Security by Insanity ....

It all began on the first interview, the moment I entered their building. I was asked to sign a four-page Non-Disclosure Agreement and was sternly warned that no recording devices of any kind were allowed in the building. It didn't seem that unheard of, so I assured them that I had no intention of recording the interview and signed the agreement, thereby swearing on my life that I would never describe to another living soul what I saw on the premises that day. To this day, I cannot reveal which motivational poster I saw framed in the only room I was allowed to see: the conference room off the entrance.


Fun with Maths

by in CodeSOD on

Ward is not a lucky man. When the two main (read: only) developers of a flash application were fired, he was called in to clean up their mess. As he puts it,

A couple of months ago, I was asked to do a small update (5 hours work) to an application made by those 2 people (they made it together, so its even worse!). This application is for a government agency, and they already paid in advance for updates. I was told just to replace the database with updated material, compile an installer and ship it.

That sounded easy enough, but after 150 hours, 20k lines of code, a a visit from one of the ex-developers, he was still finding jewels like


Three's a Crowd

by in CodeSOD on

Key and value, yin and yang, me y me compadre: all pairs. Most coders have had times when one return value is just not enough. Some sugary languages allow you to create and return arrays on the fly; others are not so helpful, forcing developers to allocate structs or return arrays of pointers.

In C++, it's easy enough to use the template std::pair and necessary for many STL templates. Maciek's company uses Java, but they wanted in on the fun and decided to write their own class.


Pop-up Potpourri: The Really Windy City

by in Pop-up Potpourri on

For many, many more, check out the previous article from the series, Pop-up Potpourri: The -693926 Days of Christmas


A lot of companies take that extra effort to handwrite the notes that their customers' enter online; it's a lot more personal than a print out. The Heavenly Ham delivery guy handing David Oranchak this personalized greeting from relatives. I think somewhere down the line they have a bug in translating their HTML ...