• Edss (unregistered)

    I'm crying. Make it stop.

  • Micah (unregistered)

    Obviously if they are ok with this function then they are ok with someone writing the overloads manually, and not even think that someone would use a script. I would be tempted to release an overload once or twice a day, and then use the other 7 hours and 59 minutes for personal reflection.

  • Daedalus (unregistered)

    Oh, I get it! there's a "...+_do+..." typo in the return statement. What a silly mistake to quit over.

  • Bernie (unregistered)

    I must be an old, blind programmer because I cannot see the Excel-specific part.

    Oh, wait, there it is... "Excel" is in the function name.

    Now I can die happy and complete.

  • (cs)

    Besides the glaringly obvious idiocy, what happens if some of the columns don't contain integers? Did the required overloads include "(double a,int b,int c...)", "(int a,double b,int c...)" etc? Because it's New Year's Eve, I can't even be bothered to work out how many combinations would be required. At least it's job security.

  • seeker136 (unregistered)

    Actually, _do is a defined variable. Still, quit now. _do not pass go. _do not collect $200.

  • meepmeepmeep (unregistered)

    Wouldn't this require something like (24^2)^(24^2) overloads?

  • Daniel (unregistered) in reply to Edss

    ++

  • Daniel (unregistered) in reply to Edss
    Edss:
    I'm crying. Make it stop.
    ++
  • dwaz (unregistered)

    The function returns a long to prevent overflow errors. But all its parameters are ints, and none of them are converted to a long before the addition.

    The results of the addition of two ints is an int, so the results of that gigantic addition is still an int, and is still susceptible to overflowing.

    Only after the addition is it converted to a long.

  • robisjarig (unregistered)

    I don't believe it. People can't be that stupid

  • jordanwb (unregistered) in reply to robisjarig
    robisjarig:
    I don't believe it. People can't be that stupid

    Yes they can.

  • mauhiz (unregistered)

    c+o+m+m+e+n+t

  • Rob (unregistered)

    If only Excel itself had some built-in way of adding stuff up...

  • Kim Johansson (unregistered)

    Ok... n elements, I'm done.

    public int addUpAllExcelColumns ( params int[] args ) {
    	int a;
    	foreach(int b in args)
    		a += b;
    
    	return a;
    }
    
  • Dirk Diggler (unregistered) in reply to Robajob
    Robajob:
    Besides the glaringly obvious idiocy, what happens if some of the columns don't contain integers? Did the required overloads include "(double a,int b,int c...)", "(int a,double b,int c...)" etc? Because it's New Year's Eve, I can't even be bothered to work out how many combinations would be required. At least it's job security.
    I think you are correct, everything should be defined as variant.
  • (cs)

    B A Bay, B E Be, B I Bickey-Bi, B O Bo....

  • (cs)

    I love the versioning on this one...Usually, 2.0 signifies that the original developers have a better grasp of what they are trying to accomplish.

    "Work dumber, not smarter. No one understands what you're up to, so you might as well not spend too much energy on it..."

  • Joseph Knight (unregistered)

    TRWTF is that Excel only has IV columns (or 256), so that's 420 variables that they don't have any reason to be dealt with! %264 code bloat even if this had been a good idea to begin with. A preposition is a word to always end every sentence with.

    captcha: ideo, as in, what a bad ideo this was

  • (cs) in reply to Kim Johansson
    Kim Johansson:
    Ok... n elements, I'm done.
    public int addUpAllExcelColumns ( params int[] args ) {
    	int a;
    	foreach(int b in args)
    		a += b;
    
    	return a;
    }
    

    You forgot to initialize "a" to zero. Nice try, though.

  • Pawel Dziepak (unregistered)
    * 20050823 - BSR - v1.0 - Adds only columns a to z. * 20050909 - BSR - v2.0 - Added support for adding columns aa to zz.
    Looks like he spent 17 days typing all these 'aa', 'ab', etc ;)
  • JJ (unregistered) in reply to Kim Johansson
    Kim Johansson:
    Ok... n elements, I'm done.

    Not quite... you have an uninitialized variable there.

  • (cs) in reply to robisjarig
    robisjarig:
    I don't believe it. People can't be that stupid

    I remember when I was a freshman in high school, learning BASIC on my TI-82...several of the early "programs" I wrote were, while not quite as abysmal as this, still fully qualified WTF's.

    I had no idea what I was doing, of course. With zero training and zero grasp of programming fundamentals, it's pretty simple to create this kind of train wreck. It usually comes from power users who have never comprehended code. They write something that works, but is butt ugly, inefficient, and unprofessional.

    I would be willing to guess this came from a power user who was asked "Hey, can you...." by someone who figures that since they guy taught them how to attach their signature automatically in outlook, he must be a God amongst men who can magically speak to computers. Having grown attached to that rep, the glorified user starts hammering out code.

    A few short years later, we get to laugh at it, and pray that the writer has since moved away from programming and found a comfortable job providing full time desktop support, or installing broadband, or anything far away from programming. Or, he has at least learned how wrong this was. We all had to start somewhere...

  • Zero cool (unregistered)

    I can't wait for v3.0 featuring added support for all of excel 2007's 1,048,576 rows!

  • Drunken Monkey (unregistered) in reply to Voodoo Coder
    Voodoo Coder:
    by someone who figures that since they guy taught them how to attach their signature automatically in outlook,

    Wait .. signature in Outlook? Wow ... that would be sooo cool .. I wouldn't need to sign my cheques anymore .. I could just e-mail them to the bank!!

  • Zero cool (unregistered) in reply to Zero cool

    16,384 columns.

  • Someone (unregistered) in reply to JJ

    It is C# you don't need to initialize variables.

  • Monday (unregistered) in reply to Kim Johansson
    Kim Johansson:
    Ok... n elements, I'm done.
    public int addUpAllExcelColumns ( params int[] args ) {
    	int a;
    	foreach(int b in args)
    		a += b;
    
    	return a;
    }
    

    Bah, I'll take the pay by line approach. I'd have to write 331,776 functions. I'd be a millionaire!!!

  • Dave (unregistered) in reply to Someone
    Someone:
    It is C# you don't need to initialize variables.

    Haven't checked, but I'm pretty sure you do for locals actually. But you'll get a compiler error about it rather than just having a random initial value. Instance fields on a class in C# 2 and later seem to be initialized to 0 by default though.

  • ShatteredArm (unregistered) in reply to Rob
    Rob:
    If only Excel itself had some built-in way of adding stuff up...

    Or, even if C# just had a way of taking in a flexible number of items of the same type as the last parameter to a function...

  • (cs) in reply to Someone
    Someone:
    It is C# you don't need to initialize variables.

    Shenanigans.

    Somebody get me my broom.

  • Mike (unregistered) in reply to Quietust

    C# initializes integers to 0 automatically. Nice try, though.

  • BSR (unregistered)

    I had a double take when I saw the initials in the code. My initials are BSR and I have used them in code to mark changes I have made. (Except for one other place where I was BSR2, because there were two BSRs in a group of 10 developers) O_o.

    Anyway, I didn't commit this felony of bad coding, just wanted to let you know...

  • Druas (unregistered)

    My eyes are bleeding

  • (cs) in reply to Micah
    Micah:
    and not even think that someone would use a script.

    Why use a script? Excel has a perfectly cromulant auto-fill function...

  • Anonymous (unregistered) in reply to Someone
    Someone:
    It is C# you don't need to initialize variables.

    This is incorrect.

  • (cs)

    Extensions are friendly

    public int addUpAllExcelColumns ( params int[] args ) {
        return args.Sum();
    }
  • (cs) in reply to Mike
    Mike:
    C# initializes integers to 0 automatically. Nice try, though.

    Contrary to what some think, C# is not simply VB.NET with a semi-colon on the end.

    In any event, if C# does do that, would you mind telling my compiler? It seems to think I need to initialize it or something...

  • Zero cool (unregistered) in reply to halcyon1234
    halcyon1234:
    Micah:
    and not even think that someone would use a script.

    Why use a script? Excel has a perfectly cromulant auto-fill function...

    a very cromulent reference

  • Patrick Harrington (unregistered)

    Something doesn't seem right on this - Excel only goes up to 256 columns, but the code looks for 702 columns.

  • Ie (unregistered) in reply to Voodoo Coder

    C# doesn't initialize to zero by merits of C#, it does it by merit of the resultant .NET IL code. So it doesn't matter if it's source was VB, C#, or whatever.

    It is a compiler WARNING in C# that default project warning threshhold converts to an error in Visual Studio 2005 and up. But it's perfectly legal.

  • (cs) in reply to Voodoo Coder
    Voodoo Coder:
    Mike:
    C# initializes integers to 0 automatically. Nice try, though.

    Contrary to what some think, C# is not simply VB.NET with a semi-colon on the end.

    In any event, if C# does do that, would you mind telling my compiler? It seems to think I need to initialize it or something...

    Just my $0.02. VB, C#, Whatever. Failure to initialize a variable is a hanging offense. At least in my town.

  • Jeff (unregistered)

    My version of excel only goes upto column IV, it doesn't allow me to go any further. So why would I need functions all the way upto ZZ?

  • Meh (unregistered)

    Python or any other language supporting keyword params would make that problem a nonissue. cap: persto

  • Bob (unregistered) in reply to Patrick Harrington
    Patrick Harrington:
    Something doesn't seem right on this - Excel only goes up to 256 columns, but the code looks for 702 columns.

    Excel 2007 has more columns.

  • (cs) in reply to Pawel Dziepak
    Pawel Dziepak:
    * 20050823 - BSR - v1.0 - Adds only columns a to z. * 20050909 - BSR - v2.0 - Added support for adding columns aa to zz.
    Looks like he spent 17 days typing all these 'aa', 'ab', etc ;)
    Probably they're still developing v3.0 now (up to 'zzz').
  • nate (unregistered) in reply to Bob

    "Excel 2007 has more columns."

    But the function was written in 2005.

  • Zero cool (unregistered) in reply to kennytm
    kennytm:
    Pawel Dziepak:
    * 20050823 - BSR - v1.0 - Adds only columns a to z. * 20050909 - BSR - v2.0 - Added support for adding columns aa to zz.
    Looks like he spent 17 days typing all these 'aa', 'ab', etc ;)
    Probably they're still developing v3.0 now (up to 'zzz').

    Nice joke. I liked it better when I told it though...

  • (cs) in reply to jimlangrunner
    jimlangrunner:
    Voodoo Coder:
    Mike:
    C# initializes integers to 0 automatically. Nice try, though.

    Contrary to what some think, C# is not simply VB.NET with a semi-colon on the end.

    In any event, if C# does do that, would you mind telling my compiler? It seems to think I need to initialize it or something...

    Just my $0.02. VB, C#, Whatever. Failure to initialize a variable is a hanging offense. At least in my town.

    Where's that? Sounds like programmer's heaven!

  • (cs) in reply to danixdefcon5
    danixdefcon5:
    jimlangrunner:
    Voodoo Coder:
    Mike:
    C# initializes integers to 0 automatically. Nice try, though.

    Contrary to what some think, C# is not simply VB.NET with a semi-colon on the end.

    In any event, if C# does do that, would you mind telling my compiler? It seems to think I need to initialize it or something...

    Just my $0.02. VB, C#, Whatever. Failure to initialize a variable is a hanging offense. At least in my town.

    Where's that? Sounds like programmer's heaven!

    I agree with initializing the variable anyway, its just good coding practice. However, if some of you guys use fxcop to analyze the code, it will warn you if you intialize unnecessarily, such as giving numeric values 0 or types null. Doesn't stop me from doing it though, because I'd rather it be clear.

Leave a comment on “Classic WTF: A Function to Quit For”

Log In or post as a guest

Replying to comment #237040:

« Return to Article