Recent Articles

Sep 2014

Stringify All the Things!

by in CodeSOD on

When Justin submitted this C# code, he knew what line to include in the subject line of the email to get our attention:

if (String.Empty == null) GC.KeepAlive(string.Empty);

Gridlock

by in Feature Articles on

In every global organization, there comes a point where someone figures out that all of those servers scattered throughout the planet aren't running at 100% capacity, and that they are sitting there going:

    Got anything for me to do?
    Got anything for me to do?
    Got anything for me to do?
	...

Free as in $5.29 Cheese Sticks

by in Error'd on

C.F. wrote, "I came really close to redeeming my 'free' cheese sticks coupon on Pizza Hut's site."


A Pentester's Paradise

by in CodeSOD on

Tom works as a pentester and, as such, gets paid big bucks for finding flaws in his clients' websites usually because he has to find less than obvious 'gotcha'-level flaws.

While testing a critical web application for a very large corporate client, he noticed some odd behavior surrounding a page that validates user logins.


Forever Alone

by in Feature Articles on

Dan’s team had a large re-engineering project. They wanted to remove some Java dependencies and replace the UI layer with their new, in-house developed standard library. Like most large maintenance projects, it was big, had a few hidden traps, but was mostly time consuming tedium. For the tedious bits, they decided to bring on a new developer.

William was that developer. He radiated confidence like an LED bulb- cold, harsh, and efficient. He said all the right things in the interview. When Dan showed him their Git repository, William nodded sagely, “I know my way around Git quite well. I appreciate the distributed part of it. It gives me the freedom to work alone. I work best alone.”

Dan’s team wanted somebody who could work with minimal guidance, so William’s lone gunman motto seemed like a good idea. They brought him on, and Dan spent the first few days getting him set up, introducing him to the code base, and helping him with any questions he had. William didn’t have many, as he reminded Dan, “I don’t need you hovering over my shoulder. I work best alone.”


Going Out of Style

by in CodeSOD on

The process of optimizing the CSS used in a web site can be quite complicated. The subtle interplay between selectors, attributes, specificity, inheritance and the DOM elements can significantly impact the outcome. Style guides can be a thing of elegant beauty, to be admired by many and revered by those steeped in the dark arts of styling.

There there's the code that George found when he took on the task of migrating a 1990's-era web site. Nobody expects code from a 15 year-old web site to be up to current standards. But there are limits. George's spidey sense started tingling when he found a file named 'css.php'. A look inside didn't do anything to turn the alarm bells off.


A Repetitive Task

by in Feature Articles on

Everyone has had the displeasure of having to perform some mind-numbing repetitive task. Those of us who know how to program computers will use our expertise to figure out a way to get the machine to serve us by performing the menial task on our behalf. After all, computers were designed to serve us. The more mundane the task, the greater the urgency to automate it so we don't need to deal with the details any more.

Devan was hired to support several legacy systems that were fraught with manual processes. A large part of his job was to find the numerous manual tasks that could be automated, and figure out ways to automate them. One of the systems he inherited allows a support person to query a set of special records for the prior production date, and update a subset of them by changing a certain date field, so that they'd be considered special in the production run for today.


Best. Soup. Ever.

by in Error'd on

"Mmmm...Nothing hits the spot quite like a big bowl of Cream of SQL Soup," writes Andrew J.


How To Demoralize Employees: A DIY Guide For Terrible Companies

by in Best of the Sidebar on

If you talk to employers about what it's like trying to attract and retain IT talent the answer is usually the same - IT'S NEAR FRICKIN' IMPOSSIBLE!! Even if you treat employees right, offer a bucket of cash, unlimited vacation, and a hammock in every cubicle, then only maybe will you attract the talent you want. So, based on this logic, you'd think that employers should treat their employees as best as possible, right? Well, by the looks of things, forum favorite Blakeyrat, found an employer that is lacking in common sense.



Failure to Leap

by in CodeSOD on

When you're a developer like Joe, and your clients all have dedicated servers, and they all call at the same time to complain that their servers have gone down, you can't help but start hoping there was an earthquake. Unless the data center housing all that dedicated hardware was wiped off the face of the earth, the bug was going to be in your software. And sure enough, in the midst of the legacy C++ module responsible for processing the day's transactions, Joe found this:

bool done = false;
while(!done)
{
    try
    {
        //I'm not sure if having a log entry for the irregular
        //Febuary[sic] 29th will destroy everything else.
        //To be on the safe side, we'll just wait 'til tomorrow instead
        Date *currentDate = new Date();
        int DOY = currentDate->dayOfYear();
        if( DOY == 60 && //day 60 is feb 29
            ( lastDigit(currentDate->year()) == 0 ||
              lastDigit(currentDate->year()) == 4 ||
              lastDigit(currentDate->year()) == 8))
        {
            while(currentDate->dayOfYear() == 60) { currentDate = new Date(); }
        }
        else
        {
            //SNIP: code that actually runs part of the maintenance
            done = true;
        }
    }
    catch(...) {} //If we failed we need to try again until we succeed
}

Dropping a Load

by in Feature Articles on

Bryan is a highly paid consultant in a position as a senior architect at a really big company. In the first part of his assignment, he concentrated heavily upon gathering requirements and designing a high-level architecture. In the latter part of his assignment, development tasks were thrown at the inexpensive offshore team.

Documents for architecture, detailed design specifications and development guidelines were written. Specifications for defining major interfaces and mocking up external systems (e.g.: databases, web services, etc.) for unit tests were written up, each with specific examples of what library to use, and how to use it to perform a given type of test. It was even explicitly stated that no external system was to be accessed from unit tests; everything was to be mocked. Real testing could be done in an integration environment.


The Erlking

by in CodeSOD on

Visual Basic’s error handling is its own special WTF in itself. For those that haven’t had to suffer through it, you can set the error-handling mode with a special On Error statement. For example, On Error Resume Next, is a delightful statement that tells Visual Basic to simply ignore errors, and continue execution. A good programmer will know to check errors with conditional statements.

More common, is the On Error Goto ErrHandler approach. As the code implies, when an error occurs, this simply executes a goto to jump to a specific label, with all of the fun that goto statements normally include.


Error Based Marketing

by in Error'd on

Robert H. writes, "I'm not sure if I'm interested in a new product called 'Internal Server Error'."


XXL XML

by in CodeSOD on

At his day job, Peter writes code for the manufacturing industry and, in doing so, works a lot with PLCs from GE. As of late, he's been working on an application that processes XML configuration files exported from GE's main programming IDE "Machine Edition" to generate extremely complex diagnostic information that the IDE doesn't provide. You know, things like, "Has that variable that you are using in a calculation ever been initialized?"

As he was looking through a 23,000 line configuration file that described the hardware setup of a particular project, Peter discovered 8,000 lines like the following that were used to store binary blob data.


The Technobabble Prescription

by in Feature Articles on

John worked for an MSP with a broad range of clients. An hour after arriving home from work one day, he received a call from a local doctor’s office. Kelly, the office manager, barely let him finish his “Hello.”

“I’m so glad you’re there! I think someone’s hacked Dr. Gates’ computer!” she cried. “He’s trying to enter patient notes, and someone else is typing on his screen- like, no joke, I’m watching it happen! I thought it might be our software developer, Jason, but he’s on vacation this week and this doesn’t make any sense. Did someone hack in? Could they do that?"


Cleveland TDWTF Meet-up

by in Announcements on

Clevelanders*! Mark and Remy will be visiting my hometown this Friday (Sept 12), and we thought it'd be a opportune time to hold a Cleveland TDWTF get-together.

If you'll be in the area, please drop me a line and we'll figure out the specifics. There's an especially good chance I'll remember to bring swag this time!


Ancient Daze

by in CodeSOD on

Although we're professionals now, we all started out as humble students - wide-eyed and innocent of the ways of proper coding practices in the corporate world. Back then, everything was new, and we had no real way of knowing whether what we were looking at was wizardry or WTF.

When C. T. was still in school, he ran across a routine for validating dates. It was written in lowly assembler. He found it fascinating, and spent a great deal of time examining its innards. It was designed to run on a 32-bit machine that lacked multiply or divide instructions. It also did something else unusual for the day: it worked on four digit years.


The Worst Bug Tracking Software

by in Feature Articles on

Rebecca's first day at Mega Thrift Stores (or MTS) didn't start well. She was hired as an assistant to Maggie, the aging head of Quality Assurance, to handle issues and complaints from regional managers about their resource tracking software. Rebecca asked if they used Bugzilla.

"We don't use Bugzilla here," Maggie told her, with the look of a stern schoolteacher.


Accuracy is Everything!

by in Error'd on

"If you insist on using Imperial weight measurements, you had better have pretty accurate scales," wrote Tom M..


Feeling Validated

by in CodeSOD on

Ugh...Address validation. Take some address strings, add to that a city, state, postal code, and country... make sure they are are all look syntatically 'valid' based on some business logic - it's not as easy as we'd hope to be able to handle EVERY possibility. But, no matter WHAT you come up with, I can guarantee that it's guaranteed to be much easier to digest than the block of validation code discovered by Mickey.

According to Mickey, there are a couple of special rules for this address validation that result in some of the WTF-ness. If an address is changed, and it's "close" to existing address, then the user needs to be prompted to confirm the address. And this prompt shouldn't take place unless the address itself has been changed. Wanna bet that the user specification for 'close' included the phrase 'you know what I mean'? That's probably the reason why the code doesn't actually address the idea of 'closeness'...the developers are still waiting for the definition.


70,000 Hours for Phase I

by in Feature Articles on

Anyone with any significant amount of experience has had to estimate a project of some complexity. The only real way to do it is by breaking down the project into major parts. Then breaking each part into smaller parts and so on, until you have a list of units-of-work that you can reasonably estimate the amount of time that will be required to do that work. Then you figure in dependencies, see what can be done in parallel, factor in available staffing, add it all up, pad by as much as you think you can get away with to account for unscheduled changes, miscalculations, emergencies and management stupidity. Finally, you put it into a project management tool and make your presentation to the Powers That Be.

Rob worked for a company that brought in three consultants to do a major rework of their database structure. One of them was being paid about $85 an hour for the sole job of filling out and maintaining a Microsoft Project schedule for the project. The first thing the consulting team did was put together a proper schema diagram of the database to be reworked. Then they tracked down all of the code that wrote to or read from each table. Armed with all of this ammunition, Mr. Project was able to put together a project time line.


The Fizz Buzz from Outer Space

by in CodeSOD on

Matteo recently interviewed a candidate that was employed elsewhere as an “architect”. His responses to the standard soft-skills questions sounded a bit rehearsed, which made Matteo suspicious, so he started asking some more technical questions, like: “What’s the difference between an interface and an abstract class?”

“Well, in some logarithms , an interface is going to be internal to the system, but an abstract class has terminators that make it external.”


Heard Around the Office

by in Feature Articles on

Gary works in a huge conglomerate. There are about 500 developers and assorted low level managers on his floor alone, and everyone is constantly on live audio-chat with their remote peers. As such, you can pretty much hear all of the conversations going on at any given time - if you listen... (see if you can guess whether the engineers or managers are in italics)

"We need to put foreign keys on auxiliary tables in order to enforce the relationships between primary and secondary data." We don't need foreign keys in the database; they slow everything down and make it harder to delete stuff. We'll just keep everything straight in code!