Remy Porter

Computers were a mistake, which is why I'm trying to shoot them into space. Editor-in-Chief for TDWTF.

Nov 2016

Trimming the Fat

by in CodeSOD on

There are certain developers who don’t understand types. Frustrated, they fall back on the one data-type they understand- strings. Dates are hard, so put them in strings. Numbers aren’t hard, but they often exist in text boxes, so make them strings. Booleans? Well, we’ve come this far- strings it is.

Tyisha has the displeasure of working with one such developer, but with a twist- they didn’t really understand strings, either. Tyisha only supplied a small example:


Indentured

by in CodeSOD on

Speaking with developers, I’m always surprised to find a surprising percentage are surprised and baffled by the “Fluent API”. This object-oriented convention is based on the Builder Pattern, and involves call chaining to construct a configured object. So, for example, if you needed to configure a SystemHandler object to have a series of LinkHandler objects, you might have something like this:

    Handlers = SystemHandler.builder()
        .AddLinkHandler(…)
        .AddLinkHandler(…)
        .AddLinkHandler(…)
        .SetConfiguration(…)
        .ConfigureOtherParam(…)
        .build();

Unpythonic

by in Feature Articles on

From: Kirby McCloy [email protected]
Subject: Concerns about SMERPS
The SMERPS project seems to be going down the wrong path. I thought our quarterly goal was for IT modernization.

The email carried no specific call to action. It barely had a point, and was little more than bad-natured griping. It also came from Kirby, the CTO. The email triggered a four-alarm underpants fire as every manager on the SMERPS project tried to guess what Kirby might possibly mean.


The Rule of Ten

by in CodeSOD on

Florian’s office has a “rule of ten”. Well, they don’t, but one of Florian’s co-workers seems to think so. This co-worker has lots of thoughts. For example, they wrote this block, which is supposed to replace certain characters with some other characters.

sbyte sbCount = 0;
// set value of new field content to old value
sNewFieldContent = sFieldContent;
while (rFieldIdentifierRegex.Match(sNewFieldContent).Success) {

        // for security reasons
        if (++sbCount > 10)
                break;

        // get identifier and name
        string sActFieldSymbol = rFieldIdentifierRegex.Match(sNewFieldContent).Groups[1].Value;
        string sActFieldName = rFieldIdentifierRegex.Match(sNewFieldContent).Groups[2].Value;
        string sActFieldIdentifier = sActFieldSymbol + sActFieldName;

        // default value for unknown fields is an empty string
        string sValue = "";

        [... calculate actual replacement value ...]

        // replace value for placeholder in new field content
        sNewFieldContent = sNewFieldContent.Replace(sActFieldIdentifier, sValue);
}

The 10x Developer

by in Feature Articles on

“You’re going to learn quite a bit from Burt,” Burt said. “He’s one of the best.”

Davide blinked. He wondered if his new boss spoke about himself in the third person as a matter of course. Cautiously, he said, “Well… I hope so?”

Alberta Highway 10X (1970s)

Coldly Fused

by in CodeSOD on

In 1989, a pair of physicists claimed to have achieved the fusion of hydrogen at room temperatures. This came as quite a shock to other physicists, since fusion was only known to happen inside of stars. Within a few months, their claims were roundly rejected. Cold fusion became synonymous with junk science.

Fast forward to 1995. when a small company wanted to make its own set of generous claims about its web application framework. Allaire, Inc (eventually bought out by Macromedia, which itself was eaten by Adobe), claimed that its Cold Fusion could solve all your web development problems. All of your web development challenges could be solved through the judicious application of CFML.


Just In Case

by in CodeSOD on

Brandon’s company had a lot of work to do, and not enough staff to do it, so they hired on some freelancers. They were careful about it, and felt like they’d hired some good people. One developer, in particular, was the kind of developer who not only understands the low-level Windows API, but actually knows how to use some of the undocumented corners of it to get things done.

Most of the module was pretty good, but when Brandon double checked on the method for escaping disallowed characters from a URL, he found some problems.


A Type of Test

by in CodeSOD on

Unit tests are a wonderful tool for proving that your code works. Ideally, when you’re using other code, like say, the .NET Framework, you don’t write tests that test the framework itself. After all, didn’t Microsoft already do that?

David T’s co-worker laughs at your naïveté. Why would you trust Microsoft? You need to make sure the framework works as advertised. Which is why their unit tests are mostly made up of code like this:


The World Tree

by in Feature Articles on

When Nate was wrapping up his senior year of college, he hunted around for a job that would hire an undergrad on flexible hours. He knew that the kinds of companies that tended to hire on those terms could often have… creative practices, but college wasn’t about to pay for itself.

He found a small shop that needed an extra hand. Extremely small- there was only one other developer, Gordon. Nate was prepared to enter a tiny shop with no real practices or procedures, because with only one developer, you don’t expect a lot of rules and bureaucracy.

Tangled tree roots Neroberg

No Account for You

by in Feature Articles on

Ed wasn’t excited about his job. He worked for a large automotive manufacturer. This is the kind of industry that might invest heavily into robots and research and development, but when it comes to managing their supply chain and accounts receivable, their IT infrastructure was frozen in amber circa 1974.

Elaine getting her revenge on the Soup Nazi from Seinfeld

The pay was fine, but the work was frustrating. Things like “Code reviews” and “refactoring” were viewed as “wastes of time” or “developers playing with toys”. Unit tests were a luxury for “lazy” developers- good developers should just be writing code that works. If the work you’re doing isn’t directly involved in getting cars built and shipped, you shouldn’t be doing it.