Comment On Classic WTF: A Function to Quit For

A Function to Quit For was originally published on July 17, 2006 [expand full text]
« PrevPage 1 | Page 2Next »

Re: Classic WTF: A Function to Quit For

2008-12-31 08:04 • by Edss (unregistered)
I'm crying. Make it stop.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:14 • by 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.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:23 • by Daedalus (unregistered)
Oh, I get it! there's a "...+_do+..." typo in the return statement.
What a silly mistake to quit over.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:26 • by 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.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:26 • by 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.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:28 • by seeker136 (unregistered)
Actually, _do is a defined variable. Still, quit now. _do not pass go. _do not collect $200.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:36 • by meepmeepmeep (unregistered)
Wouldn't this require something like (24^2)^(24^2) overloads?

Re: Classic WTF: A Function to Quit For

2008-12-31 08:39 • by Daniel (unregistered)
237012 in reply to 237004
++

Re: Classic WTF: A Function to Quit For

2008-12-31 08:40 • by Daniel (unregistered)
237013 in reply to 237004
Edss:
I'm crying. Make it stop.

++

Re: Classic WTF: A Function to Quit For

2008-12-31 08:44 • by 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.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:45 • by robisjarig (unregistered)
I don't believe it. People can't be that stupid

Re: Classic WTF: A Function to Quit For

2008-12-31 08:47 • by jordanwb (unregistered)
237016 in reply to 237015
robisjarig:
I don't believe it. People can't be that stupid


Yes they can.

Re: Classic WTF: A Function to Quit For

2008-12-31 08:48 • by mauhiz (unregistered)
c+o+m+m+e+n+t

Re: Classic WTF: A Function to Quit For

2008-12-31 08:49 • by Rob (unregistered)
If only Excel itself had some built-in way of adding stuff up...

Re: Classic WTF: A Function to Quit For

2008-12-31 08:57 • by 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;
}

Re: Classic WTF: A Function to Quit For

2008-12-31 08:58 • by Dirk Diggler (unregistered)
237020 in reply to 237009
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.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:11 • by DaveAronson
B A Bay, B E Be, B I Bickey-Bi, B O Bo....

Re: Classic WTF: A Function to Quit For

2008-12-31 09:14 • by Voodoo Coder
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..."

Re: Classic WTF: A Function to Quit For

2008-12-31 09:17 • by 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

Re: Classic WTF: A Function to Quit For

2008-12-31 09:17 • by Quietust
237026 in reply to 237019
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.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:19 • by 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 ;)

Re: Classic WTF: A Function to Quit For

2008-12-31 09:20 • by JJ (unregistered)
237028 in reply to 237019
Kim Johansson:
Ok... n elements, I'm done.


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

Re: Classic WTF: A Function to Quit For

2008-12-31 09:24 • by Voodoo Coder
237029 in reply to 237015
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...

Re: Classic WTF: A Function to Quit For

2008-12-31 09:29 • by Zero cool (unregistered)
I can't wait for v3.0 featuring added support for all of excel 2007's 1,048,576 rows!

Re: Classic WTF: A Function to Quit For

2008-12-31 09:32 • by Drunken Monkey (unregistered)
237031 in reply to 237029
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!!

Re: Classic WTF: A Function to Quit For

2008-12-31 09:33 • by Zero cool (unregistered)
237032 in reply to 237030
16,384 columns.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:44 • by Someone (unregistered)
237033 in reply to 237028
It is C# you don't need to initialize variables.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:46 • by Monday (unregistered)
237034 in reply to 237019
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!!!

Re: Classic WTF: A Function to Quit For

2008-12-31 09:47 • by Dave (unregistered)
237035 in reply to 237033
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.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:49 • by ShatteredArm (unregistered)
237036 in reply to 237018
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...

Re: Classic WTF: A Function to Quit For

2008-12-31 09:49 • by Voodoo Coder
237037 in reply to 237033
Someone:
It is C# you don't need to initialize variables.


Shenanigans.

Somebody get me my broom.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:53 • by Mike (unregistered)
237038 in reply to 237026
C# initializes integers to 0 automatically. Nice try, though.

Re: Classic WTF: A Function to Quit For

2008-12-31 09:55 • by 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...

Re: Classic WTF: A Function to Quit For

2008-12-31 09:55 • by Druas (unregistered)
My eyes are bleeding

Re: Classic WTF: A Function to Quit For

2008-12-31 09:57 • by halcyon1234
237041 in reply to 237005
Micah:
and not even think that someone would use a script.


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

Re: Classic WTF: A Function to Quit For

2008-12-31 09:58 • by Anonymous (unregistered)
237042 in reply to 237033
Someone:
It is C# you don't need to initialize variables.


This is incorrect.

Re: Classic WTF: A Function to Quit For

2008-12-31 10:03 • by durnurd
Extensions are friendly
public int addUpAllExcelColumns ( params int[] args ) {

return args.Sum();
}

Re: Classic WTF: A Function to Quit For

2008-12-31 10:05 • by Voodoo Coder
237046 in reply to 237038
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...

Re: Classic WTF: A Function to Quit For

2008-12-31 10:13 • by Zero cool (unregistered)
237048 in reply to 237041
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

Re: Classic WTF: A Function to Quit For

2008-12-31 10:15 • by Patrick Harrington (unregistered)
Something doesn't seem right on this - Excel only goes up to 256 columns, but the code looks for 702 columns.

Re: Classic WTF: A Function to Quit For

2008-12-31 10:22 • by Ie (unregistered)
237050 in reply to 237046
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.

Re: Classic WTF: A Function to Quit For

2008-12-31 10:27 • by jimlangrunner
237052 in reply to 237046
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.

Re: Classic WTF: A Function to Quit For

2008-12-31 11:05 • by 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?

Re: Classic WTF: A Function to Quit For

2008-12-31 11:08 • by Meh (unregistered)
Python or any other language supporting keyword params would make that problem a nonissue.
cap: persto

Re: Classic WTF: A Function to Quit For

2008-12-31 11:13 • by Bob (unregistered)
237062 in reply to 237049
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.

Re: Classic WTF: A Function to Quit For

2008-12-31 11:20 • by kennytm
237063 in reply to 237027
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').

Re: Classic WTF: A Function to Quit For

2008-12-31 11:25 • by nate (unregistered)
237064 in reply to 237062
"Excel 2007 has more columns."

But the function was written in 2005.

Re: Classic WTF: A Function to Quit For

2008-12-31 11:25 • by Zero cool (unregistered)
237066 in reply to 237063
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...

Re: Classic WTF: A Function to Quit For

2008-12-31 11:27 • by danixdefcon5
237067 in reply to 237052
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!

Re: Classic WTF: A Function to Quit For

2008-12-31 11:36 • by pitchingchris
237069 in reply to 237067
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.
« PrevPage 1 | Page 2Next »

Add Comment