Recent Articles

Jun 2010

Avoiding the Exception

by in CodeSOD on

"I found this interesting tidbit while making some changes to a .NET application," Tim Kowalski writes.

"Although the original developer claims to 'spend 9/10ths on the rule and not the exception', I would argue it's more like 5/10ths on the excuse, 4/10ths on the rule, and 1/10th avoiding the exception."


Pipe Up

by in Feature Articles on

Amit checked his latest code in and turned to more interesting work. It didn't take much to be more interesting than writing a CSV parser. That was kid's stuff, really. With the low-hanging fruit out of the way, Amit could focus on the more mission critical aspects that were on tight deadlines. He had designed the module with a little extra polish; it was generic and should be easy to modify in the future. That was a smart decision, as a few days later the requirements changed. The application also needed to be able to handle pipe (|) separated values data. Since Amit was tied up on more important work, his manager stopped by to ask a few questions.

"How difficult do you think this would be?" John asked.


Warts and All

by in CodeSOD on

"We need to make sure that the new PL/SQL version that runs on Oracle will work exactly as it does on SQL Server," stated the directive given to Andy by his supervisor.

Andy had been tasked to port over a T-SQL function which, when passed valid string, would convert it into a data format that could then be returned back to the calling application and submitted to a label printer to produce a bar code.


Whoa, Batman!

by in Error'd on

"I'm not sure if that means he's the problem," Chris F. wrote, "or we need to get him to fix the problem."


Venting Frustration

by in Feature Articles on

It takes ambition and funding to build the "best datacenter in the world". Bi-located on the East and West coast, with multiple fat pipes, doubly-redudant power generation, armed security guards, and a Network Operations Center with giant plasma screens scrolling network statuses that are monitored by a 24/7 staff always looking busy, such a datacenter would serve only the highest-end clients. It takes one more key ingredient though: timing. Building a high-end datacenter in the middle of the deepest recession in decades isn't the recipe for success. Only a handful of clients ever moved in, and they were moving back out when the datacenter decided to shut down operations for good. Nearly everyone had been laid off, which left Ryan as the lone IT guy.

It was a lonely, and slightly creepy, position. Day after day, he sat alone in an abandoned office building, with only the security guard for company. During those weeks, his mind wandered, inventing noises where there were none, inventing strange interpretations for the noises that were there. He kept his sanity and balanced his time between building walkthroughs, marathon Minesweeper sessions, and browsing IT humor sites to remind himself that things could be far worse than drawing a check to warm a chair.


"True" and True

by in CodeSOD on

"We have an old codebase where strings are used as a swiss army knife," writes Jimmi Hested, "almost everything that goes in or out of a function is ends with a .ToString(), even it's already a string... and sometimes even if it already ends with .ToString()."

"Here is a bit of code from our web front-end. Not only is there a try/catch (just to make sure everything works), but the original developer felt a string was way better than a bool."


Critically Conditioned

by in Feature Articles on

brykmantra @ FlickrBeep. .... Beep. .... Beep. .... Peter stared aimlessly at the heart monitor above his wife’s hospital bed, watching the green lines zig... then zag. Then zig... then zag. It was calmingly hypnotic, especially after five long hours of sitting by her side in the cardiac unit, waiting around for test results.

Suddenly, the steady pace of beeps increased and Peter snapped out of his daze. Looking around, he spotted the culprit: the doctor was in route and was making his way towards the bed. “I just wanted to let you know that we’re still waiting on the final enzyme analysis,” the doctor said as he flipped through papers on his clipboard, “the first tests were… hmm… inconclusive. So, it shouldn’t be much longer.”


That's One Way to Fulfill a Requirement

by in CodeSOD on

Everyone responds to new requirements on already-behind-schedule projects in a different way.  Many people feel anger, and try to find an innocuous way to show it.  Others, realizing this might finally be their chance to shine, take it as a challenge with a smile.  Still others, like Gary's colleague Steve, find a way to fulfill the requirements without actually fulfilling the requirements.

With less than a week remaining till the deadline of a 4-month-long project, Gary and Steve's boss demanded everyone write Unit test code.  Gary spent hour upon unpaid overtime hour adding as many unit tests as he could come up with, while Steve left by 5pm each day.  Their boss also asked them to set up a nightly script to perform the unit tests automatically.  Each night Steve's test set would always come back with 100% successful results.


Benched

by in Feature Articles on

Genista on Flickr - http://www.flickr.com/photos/genista/6496754/When Sally graduated from college, she had aspirations of finding a career in project management. And much to her delight, she landed a great position with a large, internationally-based consulting firm. In addition to billing out fresh college graduates at obscenely high rates, the company developed obscenely expensive software for large enterprises.

With the vast majority of the firm’s software development being performed at the other end of the world, they relied heavily on teams at the client’s site to define application requirements and act as the “face” for the offshore developers. Sally was hired to work on these types of teams and, and to her, it seemed like a perfect fit.


Maximum Pad

by in CodeSOD on

Brian's company needs to track financial information indexed by 100 digit routing numbers. Now, obviously, not all of those digits are significant, so if a user enters "123", the application needs to be smart enough to pad out the other 97 digits with leading zeros. Sane people might think this should be implemented as a one-line call to a built-in method. The more DIY among us might waste time building up a for loop. And, of course, a LISP fan would simply torture future coders with recursion and parentheses.

Then there's this approach that Brian found:


On the Job Training

by in Feature Articles on

"None of our customers' web servers are online!" was not the kind of thing Ryan wanted to hear in the morning.  Nor was it the kind of question Ryan wanted to hear from the 15 different department heads and administrators all shouting on the conference call that morning.  Luckily (for everyone but Ryan), Ted from Net Operations was on the call. Ted was one of those hands-off system administrators who found that it was far easier to delegate work to someone else and leave early for a bar.

After 10 minutes of bickering, Ted announced that he had found the root cause of the problem: Ryan. He announced to the group that Ryan, in his ignorance and naivety, had deleted all of the customers' web servers from production.  In shocked realization that today might be his last day on the job, Ryan was unable to speak at first, but one detail gnawed at him - throughout it all, he had followed the steps that Ted had given him to the letter.  Ryan needed answers - if Ted said that he did indeed wreck the Production environment then it was Ted who would show him.

The Training Process


1's and 0's

by in CodeSOD on

Consider "0010000000100000". It's a string filled with nothing but "1" and "0" characters. Now, unless such a string is part of some classroom assignment where the goal is to programmatically convert Based 2 to Base 10 — or, perhaps, existing in some highly-limited and/or perverted language like MUMPS — there is never a good reason for it to exist in a program.

Because there are so many more appropriate data types — a boolean array, an integer bitmask, or even an integer array, just to name a few — a "boolean string" is a canary in the coalmine. If it's in an application's codebase, then chances are, there's something seriously wrong with that code. If, perchance, such a string is found in a VARCHAR column in some database, then something isn't just seriously wrong, the application is nothing short of an epic disaster.


A Gracious Grace Period

by in Error'd on

"Some applications offer you a grace period before your password expires," Michel van Zoest wrote, "I think I'll leave instructions in my will to have one of my great-great-great-great-great-great-great-grandchildren change the password for my database in about 50539024859478222 years. If we survive the death of our sun, that is."


The Interupting Rebutter, The Final Word, and The Jury Rig

by in Tales from the Interview on

All three of today's Tales from the Interview are from R Huckster.


The Interupting Rebutter
The job sounded right up my alley: it was in a field that I was experienced in, offered a laid-back environment, and employed a young and hip workforce. After passing a few programming brainteasers and describing my experience in the field, I thought I was a star candidate. That is, until the interviewer asked me specific details about my previous job.


IsListconntSmalleThaOne

by in CodeSOD on

If Peter Moberg were to give a single criticism of his colleague's work, it would be that it represents a complete and total misunderstanding of the principles of software development.

Criticisms #2 and #3 would probably center around typos/misspellings and completely superfluous code. Today's example illustrates all three.


Secured Typing

by in Feature Articles on

Credit: sonrisa electrica @ flickr Gary's company has an "enterprise" application, and like any enterprise application, it was built to be all things for all people, by people that didn't have a clear picture of which things it was supposed to be to whom. While a customer could, in theory, install and configure it on their own, pretty much everyone paid for a consultant to handle the setup for them. Gary was one of those consultants.

Gary was scheduled to be at the client site for a week, which was plenty of time for the basic install and configuration. But before he could even get three steps through the door, the company "Security Czar", Norman, tackled him and then locked him in a dingy, windowless room with a two foot tall stack of forms. Of course, Gary was used to signing NDAs and the like, but Gary's management usually handled the negotiations, and the documents were usually a few pages of legalese, not a Neal Stephenson book.


Well-Formed XML

by in CodeSOD on

Diego was excited. A vendor — one that, for the record, he had no choice but to work with — finally put together a web service. This was big news because it meant that Diego would no longer have to battle proprietary TCP protocols to get data extracts; he could use a simple, well-established protocol to download the data he needed.

When the vendor delivered the service documentation, however, Diego was a little disappointed. It was a little more... simple... than he had imagined.


The Long Walk

by in Error'd on

"I searched for a route to walk from Southampton to Edinburgh(UK)."Albert writes," but for some reason, Google Maps wants me to slip over the border into France, back to UK, back to France, then again to UK!"


Surpassing the Master

by in Feature Articles on

Jibran turned in some questionable programming code when he was a student in college. Then again, who didn't? It's a student's sacred right to drive instructors to drink. There are no WTFs in student code; everyone has to learn sometime.

Unfortunately, Dr. Talbot's 100-level Java class focused more on providing barriers to learning. Talbot's voice had a nasal drone that would make bagpipes cringe but was so monotonous it could put an elephant under. Nor did he have any ability to organize a classroom session; he delivered material in a haphazard ramble that only covered half of the the outline. Jibran generally dozed through the session, and if he was lucky, woke up before it ended and caught the day's assignment.


The Quotient ID

by in Representative Line on

To say that the codebase at Andy’s client is sub-optimal would be generous. It’s a kludge on top of a kludge that was cobbled together by countless developers over many years. And as with many large and unwieldy information systems, distilling this beast into an understandable form is a challenge superseded only by the actual maintenance of the code.

As such, a brief snippet — a representative line if you will — offers perhaps our best glimpse into the heart of the system. And what a better place to look than its most tragic part: the database. Following is a portion of a line (a SELECT statement) that illustrates a pattern used over and over within the code.


Liberal Leave

by in Feature Articles on

It’s hard to believe that it’s almost summer. Actually, that’s not true; summer basically comes at the same time every year, and it’s slowly transitioned to through a period known as “spring.” But what is hard to believe is that just three short months ago, we experienced the most brutal winter ever.

Dubbed The Snowpocalypse and Snowmaggedon, the 2010 blizzards dumped an obscene amount of snow on the Washington DC area. So much that even the monstrous machines dedicated to clearing said snow were no match. “Due to blizzard conditions and near-zero visibility on the roadways,” emergency services announced after one storm, “to protect the safety of city employees and residents, all snowplowing operations have been temporarily suspended until weather conditions improve.” Now that’s some serious snow.