When it comes to clever coding, there’s a fine line between amazingly brilliant and incredibly stupid. Take DocumentDotWrite.js, for example. It's a single-line JavaScript file that’s served (http://rmd.atdmt.com/tl/DocumentDotWrite.js) seemingly all the time by Microsoft’s Atlas advertising platform.

function DocumentDotWrite(s){document.write(s);}

 

I want to believe that there’ some Ninja JavaScript-fu going on here that my feeble mind cannot possible understand. The Daily WTF's own forums, which seems to be the only place on the ‘net where this code has been discussed, conclude that it’s a callback function for a poor man’s bind()… or some sort of ad-block/filter busting code… or even a “coding by phone” that was taken a bit too literally.

I guess we’ll never know. Like so many instances clever coding, until we hear from the actual developer behind DocumentDotWrite.js, we can only guess as to whether it’s a complete WTF or an amazing hack.

Peter, on the other hand, didn’t have to guess. When he saw a a bit of seemingly clever code, he was fortunte to have the original developer — and team lead — in the cubicle next to his. This was the code he had uncovered.

public static object[] CreateObjectArray(object o1)
{
    return new object[] { o1 };
}

public static object[] CreateObjectArray(object o1, object o2)
{
    return new object[] { o1, o2 };
}

public static object[] CreateObjectArray(object o1, object o2, 
        object o3)
{
    return new object[] { o1, o2, o3 };
}

public static object[] CreateObjectArray(object o1, object o2, 
        object o3, object o4)
{
    return new object[] { o1, o2, o3, o4 };
}

public static object[] CreateObjectArray(object o1, object o2, 
        object o3, object o4, object o5)
{
    return new object[] { o1, o2, o3, o4, o5 };
}

public static object[] CreateObjectArray(object o1, object o2, 
        object o3, object o4, object o5, object o6)
{
    return new object[] { o1, o2, o3, o4, o5, o6 };
}

public static object[] CreateObjectArray(object o1, object o2, 
    object o3, object o4, object o5, object o6, object o7)
{
    return new object[] { o1, o2, o3, o4, o5, o6, o7 };
}

public static object[] CreateObjectArray(object o1, object o2, 
    object o3, object o4, object o5, object o6, object o7, 
    object o8)
{
    return new object[] { o1, o2, o3, o4, o5, o6, o7, o8 };
}

public static object[] CreateObjectArray(object o1, object o2, 
    object o3, object o4, object o5, object o6, object o7, 
    object o8, object o9)
{
    return new object[] { o1, o2, o3, o4, o5, o6, o7, o8, o9 };
}

“Oh that,” Peter’s coworker explained, “I sometimes forget the syntax for creating an array. You know, between the ‘new’, the square brackets, the commas, the semicolon… it can get a bit confusing. I figured this was just easier.”

At least Peter had his answer.