Linux kernel loc

The task Tama set out to accomplish was rather straightforward. One of the clients had a legacy inventory management application, and they needed a simple text field added to an entry form.

Though he'd never seen the code, and the word "legacy" sent chills through his spine, he was confident he could get it done quickly and painlessly. Without hesitation, he downloaded the sources and dug in to acquaint himself with the codebase.

The database migration went easily, but the actual application—a WebForms solution spanning multiple projects and hundreds of files—turned out to be the strangest code Tama had ever seen. The first thing that caught his attention was an abundance of redundant and pointless code. Gems like


bool refreshView = false;
if (refreshView)
{
    //...
}

and


if (val == null || val.IsNull)
{
    return false;
}
return true;

popped up in nearly every method, bloating them and making Resharper wince in pain as it rendered thousands of warnings. Then there were the methods themselves. Instead of generics, each table column had multiple overloads of various methods with word-for-word identical contents.

The more Tama kept digging, the more he kept cursing at the obviously novice programmer who'd written the application. The code was atrociously unmaintainable, and even the slightest changes required modifying tens of code files across different projects. Instance methods doing nothing but calling out to static ones, multi-line calculations returning a constant value every time—it was as if the previous developer's sole goal was to write as much code as they possibly could, without any regard for proper coding standards or common sense.

Finally, Tama realized what was really going on.

public static string GetXMLString()
{
    if(_DefinitionString == "")
    {
        System.Text.StringBuilder tbf = new System.Text.StringBuilder();
        tbf.Append(@"<XMLDefinition Generator=""SpeedyWare Table Designer"" Version=""3.4"" Type=""GENERIC"">");
        _DefinitionString = tbf.ToString();
        tbf.Append(  @"<ColumnDefinition>");
        _DefinitionString = tbf.ToString();
        tbf.Append(    @"<Column ColNumber=""0"">");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnName>StateId</columnName>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnUIName>State</columnUIName>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnType>Number</columnType>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnDBType>int</columnDBType>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnLengthSet>10.0</columnLengthSet>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnDefault></columnDefault>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnDBDefault></columnDBDefault>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnIndex>Y</columnIndex>");
        _DefinitionString = tbf.ToString();
        tbf.Append(      @"<columnUnique>Y</columnUnique>");
        //...
    }
}

SpeedyWare Table Designer, Tama thought to himself.

It was all generated code, or at least used to be at some point, since neither the actual generator nor the sources were anywhere to be found. But why was it so terrible? What possible motivation could lie behind utterly defeating the purpose of a StringBuilder by calling ToString() after each line, among all the other sins and indecencies?

The answer to that question was a quick Google search away. Looking past the various warez sites, Tama managed to find SpeedyWare's webpage, where a large heading proudly boasted:

Write 10,000 Lines of Code in 10 minutes!

It seemed that on some fateful day in the past, someone had had the great idea to make a simple app generator. Then Marketing had come along to milk the idea for all it was worth: This tool will write your business apps for you! Marketing promised that it would generate thousands of lines of code, since lines of code were obviously the best metric of effort and quality. Perhaps their management took this claim literally. Perhaps a customer complained that they only received 9,995 lines of code. Whatever the reason, the developers had been forced to bend and twist the generator until it extruded the magical 10,000 lines at any cost.

How well did it work out for the company? Tama scrolled down the webpage, expecting to find testimonials from happy customers announcing how much time the tool saved them. Instead, he found this little blurb:

Technical support for SpeedyWare Table Designer was discontinued on December 31, 2015 as part of our company ceasing operations.

As it turns out, even 10,000 lines of code will not save you if there's not a single good one among them.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!