Remy Porter

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

Oct 2014

The Alpha-Team

by in Feature Articles on

In 2010, a crack development team was formed inside of a Fortune 500 company. These developers promptly escaped the maximum security Project Management Office and instituted an Agile Scrum. Today, they survive as green-field developers. If you have a problem, if traditional corporate IT can’t help, and if you can find them, maybe you can hire… Alpha Team.

When Thom interviewed at said Fortune 500 company, he didn’t know he was interviewing for Alpha Team. He assumed that it would be like any other huge enterprise development shop- tedious line-of-business applications that helped ship widgets but didn’t do much more. The product and the team was sold to him as being very exciting, and he liked the idea of the stability a large company offered, so Thom joined the Alpha Team.

The team room was slightly larger than the inside of a large van. John, the team lead, greeted Thom with a sly grin. “Great to have you on the team. You’ll be sitting between Albert and Murdock. I hope you don’t have any plans for lunch- today’s our weekly team lunch. Good chance for you to get to know everyone.”

The team’s architect, Murdock, grabbed Thom for a few minutes to brief him on the application’s architecture. It wasn’t surprising: a SQL server backend, a web-service based middle-tier, and a hybrid ASP.NET and WebForms presentation tier. “This application is extremely flexible,” Murdock said. “That’s the main goal, really. We’ve got it set up so our business analysts have a lot of control over the display, so that we aren’t wasting time just changing field names around.” The exact details were simply described as “magic”, which Murdock didn’t have time to explain right then; “It’s documented, and I need to crank on a few tasks, our burndown is terrible this sprint.”


The Beginning of the Zend

by in CodeSOD on

Karol found a program that needs to look at a timestamp, and determine if that timestamp is before or after an expiration date. The code that was handling this looked like this:

public function _isSmsCodeExpired($id)
    {

        $genDateStr = $this->db()->query('SELECT date FROM table')->fetchColumn();

        if (empty($genDateStr))
        {
            return true;
        }
        
        $expireDateArr = array();
        $intervalSec = 120;

        $genDataTmp = explode(' ', $genDateStr);
        $genDataArr = explode('-', $genDataTmp[0]);

        $expireDateArr['year'] = $genDataArr[0];
        $expireDateArr['month'] = $genDataArr[1];
        $expireDateArr['day'] = $genDataArr[2];

        $genDataArr = explode(':', $genDataTmp[1]);

        $expireDateArr['hour'] = $genDataArr[0];
        $expireDateArr['minute'] = $genDataArr[1];
        $expireDateArr['second'] = substr($genDataArr[2], 0, 2);

        $intervalMin = (int) $intervalSec / 60;
        $intervalSec = (int) $intervalSec - ( $intervalMin * 60 );

        $expireDateArr['second'] += $intervalSec;
        $expireDateArr['minute'] += $intervalMin;

        $expireDateArr['second'] += $intervalSec;
        if ($expireDateArr['second'] > 60)
        {
            $expireDateArr['minute'] += 1;
            $expireDateArr['second'] = $expireDateArr['second'] - 60;
        }

        if ($expireDateArr['minute'] > 60)
        {
            $expireDateArr['hour'] += 1;
            $expireDateArr['minute'] = $expireDateArr['minute'] - 60;
        }

        if ($expireDateArr['hour'] > 24)
        {
            $expireDateArr['day'] += 1;
            $expireDateArr['hour'] = $expireDateArr['hour'] - 24;
        }

        $daysInMonth = date("t", strtotime($expireDateArr['year'] . "-" . $expireDateArr['month'] . "-01"));

        if ($expireDateArr['day'] > $daysInMonth)
        {
            $expireDateArr['month'] += 1;
            $expireDateArr['day'] = $expireDateArr['day'] - $daysInMonth;
        }

        if ($expireDateArr['month'] > 12)
        {
            $expireDateArr['year'] += 1;
        }


        $expireDate = new Zend_Date($expireDateArr);
        $now = new Zend_Date();

        if ($now->isEarlier($expireDate))
            return false;
        else
            return true;
    }

Line by Line

by in CodeSOD on

In the bowels of a business unit, a director got a great deal on a third party software package. He bought it, without talking to corporate IT, and then was upset when it couldn’t gracefully integrate with any of the corporate IT assets. Eager to throw good money after bad, the director hired his nephew’s consultancy to build an integration tool to make his new toy work.

A few months later, the users complained about performance, and somehow, fixing this thing became Jeff’s problem. The process was simple enough: slurp enterprise data out of a text file, and pass the data on to the third-party tool. It didn’t take Jeff long to figure out why it performed poorly:


Enterprise GUID

by in CodeSOD on

Jonathon recently got a new co-worker who is an enterprise systems developer, with an emphasis on enterprise. For an enterprise-level WTF, today’s code is short, but it packs itself up with everything it could do wrong.

using System;

namespace Business.Common.Services
{
    /// <summary>
    /// Guid service.
    /// </summary>
    public class GuidService : IGuidService
    {
        /// <summary>
        /// Initializes a new instance of the System.Guid structure.
        /// </summary>
        /// <returns>A new GUID object.</returns>
        public Guid NewGuid()
        {
            return Guid.NewGuid();
        }
    }
}

Threadbare Down Under

by in Feature Articles on

Organizing a small development team is an art. Organizing a large team is a challenge. Organizing a global team, scattered across eight countries and four continents is a job for Sisyphus.

Scali’s company was in exactly that situation. Their self-appointed Sisyphus was actually named Steven. Steven’s slot on the org-chart was “Chief Application Architect for the Australian Region”, or CAAAR for short.