- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
First!
Admin
Yea, I'm inherently lazy, so, the third time I type the same thing, I stop working on whatever I was doing, and start looking for a way to make it easy.
One of my first programming gigs, I ended up with this "hell job" that had been passed down from a predicessor, where I had to take an *entire directory of log files* and compile from them a list of duplicate jobs. The previous guy had done it manually(!!!!!) and it took days.
I looked at it, wrote a single line (illegible) perl script, which spit out a file with the duplicates, and the person who submitted them. Took about twenty minutes. Then I went back to work on the other thing, and every time my boss stuck his head in to "see how it was going" I told him it was done. He fancied himself as having a sense of humor, so it wasn't until it was actually due (four days later) that he actually asked for it. I had to dig the printout out from under the pile of crap on my desk. He professed amazement, and I showed him my script...He was too smart to fall for that though, and commended me for my "after-hours" dilligence. Took me a week to convince him.
When that company went out of business, I got a call from the people we'd been doing that job for, and I went in to find that they'd hired another guy who was spitting nails because of how much my previous employers had charged, and of their assertion that "It was impossible to do programatically." They never told 'em that I'd automated it, and had charged them for hours of work right up until the end.
Admin
This is so crazy, it just might work! ;)
I mean, there's no telling how many times that function is already used throughout the entire company... The EASY part is to re-write the function, it's the updating of all other dependant code that would take some time.
Admin
Worse than add(a,add(b,add(c,add(d,add(e, snip )))))))))))))))))))))))))))))))))))))))))))))));
They might need this technique anyway to add the numbers in the reverse order.
Admin
Oh unholy of unholiest, how I have not missed you! I have before gawked into the Maw of Terror yet I live to tell the tale. At my previous job I programmed Excel "applications". Those who worked there, utter non-techies to a person (you know, the kind of people who calls filling in numbers in a spreadsheet "programming") could be expected to create just this level of abominations in their (luckily very rare) forays into programming VBA.
However, since the company of this WTF obviously knows enough to link Excel with .NET code, how in all the bleeding hells of The Eye of Argon can they NOT know of the VBA/Excel2K Range object?! And use it. Instead of simply adding together all the sixbloodyhundred parameters?!
Also, won't this risk shunting the parameter stack all the way into hyperspace?! I've never even heard of a 600-parameter function signature before!
Admin
But just wait until Excel 12 arrives with 16000 (well, 2 ^14) rows. I'd love to watch someone make that edit!
David
Admin
...no... eyes bleeding... pain is incredible... <POP> ARGHHH!!! My eeeeeyyyyee has exploded! THE PAIN!!! <POP> AAIIEEEEEEEEEEEEEEGGGGH!!!! MY EYES!!!
stumbles blindly downstairs and fall heavily on piled up MSDN cdroms, cutting throat on broken crdom in the process
Admin
In all seriousness, I can see how something like this might make it into production. A single programmer is assigned to create an application or application framework. He has limited vision and an extremely thick skull. The application makes it into production without a lick of code review. Then others are assigned to work with the framework and discover the horror within. But the app's already in production, so changes to the framework would risk bringing down the whole Jenga tower or initiating another round of full end-to-end testing. So it becomes easier to patch, adapt, and come up with nicknames like "the blamework."
Admin
I agree... I suspect that numerous people just looked the other way when they found it. Sad, but probably true.
I guess the solution is to leave it for backward compatability, and write a new function and instruct the rest of the team to begin using it from then on...eventually it may weed itself out. *crossing fingers*
Admin
If I was given this task, I would probably pout for several hours. Then I would have a gestalt realization, go back to the manager, and convince him that writing 600 overloads of this function will take several months; then I would go back to my cube and write a script to generate all 600 overloads, grab my laptop, head straight to the airport and catch a standby flight to the beach. I would then take three months vacation, logging in every day to check in a few more of my "deliverables". The boss has no idea -- if he can't conceive of a way to make 1 function handle multiple cases, then it would certainly never occur to him that somebody could write code to *generate* code to handle multiple cases. Best. Job. Ever.
Admin
As the developer of a few .NET blameworks at my job, I find myself wishing that the [Obsolete()] attribute could deliver a tiny little electric shock upon compilation.
Admin
you forgot the required <sarcasm> tags
Admin
BAAAAA!!!
For the sake of all that is holy! How freaking hard is it to replace calls to this "function" with calls to the excel sum function passing it the range object representing all the cells in the desired row?
Even if you didn't want to remove existing calls to the function you could NOT ADD NEW CALLS. The real WTF is not that somebody wrote this function, it is that nobody at this company is smart enough to stop using it.
I have to go now, the stupidity of this has given me an aneurysm.
Admin
Actually, you'll need around 21,040,543,606,193,494,028,963,959,531,521,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000 function definitions.
You're making the assumption that the un-used arguments will be consecutive and terminal.
Start with
public long addUpExcelColumnsAandB(int a, int b)
{return(a+c);}
public long addUpExcelColumnsAandC(int a, int c)
{return(a+c);}
...
public long addUpExcelColumnsAandQandAXandMEandZZ(int a, int q, int ax, int me, int zz)
{return(a+q+ax+me+zz);}
Admin
More likely suggesting anything different than the 'defined specifications' will result in castigation and redicule from the company's 'star' programmer who designed and wrote the spec and won't accept that anyone else in the company could have any idea what's going on.
What, you think you can replace my 600+ parameter function with a couple lines of code (that use an Excel function)? That's simply not possible, whatever solution you have would simply not scale for our 'enterprise' application like this function can (we can just add another couple thousand parameters to accomodate the size in crease in the new version of Excel and we'll be good to go). What do you mean your solution scale and would require no changes regardless of the number of parameters (since it would sum the row, not a list of parameters), obviously you don't know the first thing about brilliant programming.
</Sarcasm>
Admin
I think you’re missing the point. By avoiding loops the function enjoys a huge boost in performance.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
<o:p> </o:p>
W.T. Franklin
Admin
That's this company's version of encapsulation.
Admin
I dub this technique "encrapsulation."
Admin
Don't quit! You need to go in and ask for a raise right now. If you are not granted one, then quit. The reason you should get a raise is because they were probably paying the guy who wrote that the same amount of money they are paying you. Do you really want that on your conscious?
Admin
That's brilliant!!! We could probably make a whole bunch of "faces" using typographical symbols like that so when the reader turns their head sideways, they see a "face" instead of some letters and punctuation! This would be excellent on those web boards where images or HTML aren't allowed! This is so Web 2.0...
( ; (hint: turn your head 90 degrees clockwise!)
Admin
Probably not java, you cannot have more than 255 parameters
http://javaspecialists.co.za/archive/newsletter.do?issue=059&locale=en_US
Admin
Admin
first time i saw this, i ignored it. second time, i have to say - there is no 'select case' in any C based language....... and Else Case is supposed to be Case Else, even in languages which do have select case (like vb). and it's adding a string? with single quotes?
.... am i totally missing an obviously sarcastic pseudo-code kinda thing?
Admin
As has been said before, the REAL wtf is that Excel's last column is IV not ZZ. And the REAL wtf is that people are still talking about 702 parameters...
Admin
It'll be nice to provide us a function call as well.
Admin
for shure ^^
this MUST be a coke !?!
... no one with at least 5 minutes of programming experience would create a method like this ...
Admin
Mike should make the overloaded functions "add" everything over GF(2^32).
Admin
I can't believe that, are you kidding on us?
Friedrich
Admin
600 plus??? How about something close to practical infinity. There are (26+2626) cells any combination of which could be blank. This should lead to (26+2626) factorial combinations. The functions would not be completed before the heat death of the universe.
Admin
Yeah lol... I thought it'd be a bit funny if I made up ANOTHER useless acronym... Apparently, it was a bit funny, although some found it annoying... I find the annoyance it created funny as well though, so all in all, I think it did what I wanted ;-)
Admin
The function adds the numbers and ignores any strings which are non-numeric. With dates it converts them to numbers (I don't remember how it does this) and adds them to the sum. So dates in the cells will mess up the total, but strings will not.
Admin
For me the bigger WTF is the idiot who calls this thing...
Tell me how
<FONT face="Courier New" size=2>int result = addUpAllExcelColumns(a, b, c, d, e, ..., zz);</FONT>
is going to be any easier than just doing what the method itself does...
<FONT face="Courier New" size=2>int result = a + b + c + d + e + ... + zz;</FONT>
Not that either of them is the ideal solution. I just can't figure how any developer using the code would find this function helpful, useful, worthwhile....
Admin
Admin
XFD is the last column in Excel 2007.... but yeah, ouch, doh!
Admin
public long addUpAllExcelColumns( params int a[] ) {
long retval = 0;
foreach( int i in a ) retval += i;
return retval;
}
// Voila.
Admin
My guess would be that the original programmer wrote a script to write those functions.
Admin
This function is actually not a bad idea. This is the best way to keep your job. You can't be fired if no one can take over your work. Plus if you create insane functions like this you can brag to your idiot boss of how many lines you've coded and spend the rest of the day reading TheDailyWTF. A stroke of genius if you ask me. So many lines of code and such little real work done. I refuse to believe that anyone that even knows what a function is would actually write this code believing it was the best way. I refuse to believe it. If this function was not written to either keep a job or impress a boss with LOC, then it is a fake.
Admin
Hilarious. Many comments are written about the best way to do this. I would say, now that our friend(s) already deliver this code, the best way could be to copy&paste those lines ;).
Code-Re-Usability : ISO 9126 ...
HaHAHAhAhAHahahAHAhAHAhAHAhhhaAHhHAHhhahaa..aaaaarrggghhhh
:x
Admin
The real WTF is that 1+2+3+4 is shorter than addExcelColumns(1,2,3,4).
captcha: captcha
Admin
Just for shits and giggles, I wrote a quick script to generate a C# method with 26^2 parameters and Visual Studio 2005 handled it like a champ.
Admin
I wonder whether anyone else noticed that where you wrote
/* Snip 100 lines */
you actually snipped only 99 lines. (Unless, of course, there was a line in there that doesn't fit into the regular pattern.)Admin
Nice VICModem you have there ;-)
Admin
well... why not just use nix? :
<font face="Courier New" size="2">/
hint = gcc -g -c addUpAllExcelColumns.c -o addUpExcel-0.1.so -Wall
/
#ifdef _DEBUG
#include <errno.h>
#include <stdio.h>
#endif
#define _XOPEN_SOURCE 600
#include <stdlib.h>
extern long double addUpAllExcelColumns(const char *row)
{
long double total = 0; / total /
long double this; / current /
int i; / misc */
for (i = 0; row[i]; i++){
if ((this = strtold(row[i], (char *)NULL))) {
total += this;
}
#ifdef _DEBUG
else / if (this == 0) */ {
if (errno == ERANGE){
fprintf(stderr,"Not adding %s\n",row[i]);
perror("strtold(3)");
}
}
#endif
}
return total;
}</font>
or something to that effect.... now, we just have to make <font face="Courier New">(char **) row</font>
Admin
Joe: >to Boss
Joe: There's something about "_as"... or to the constant reference to "_as"...that we feel is significant."
Joe: Now... "_as" had us really stymied... until we ran across this wtf.
Joe: During oversight, our programmers kept seeing recursive references to "_as"... and "af"
Boss: And "_do".
Joe: ...and "_do".
Joe: Well "_do"... is still a mystery, and may be insignificant...
Joe: but the constant reference to "_as" has got to mean something...
Joe: At least we think it does.
Boss: okay Joe - what have you got?
Joe: Well.. the only appreciable use for "_as" in this instance - was to SUM( "a" and "s" )
Joe: We suspect... or we believe... that "_as" is really an alias for "af".
Joe: Now we can prove this... by giving this to a WTFU graduate...
Joe: ...they'll have to substitute NULL for the value of "af"...
Joe: but, this should raise an error()----> signaling the original author(s).
Joe: If the author(s)<---- realize that "af" has become NULL...
Joe: ...they might re-define the "_as" formula!.
Joe: if they do... we'll know that "_as" was really designed to SUM( "a" and "f" );
Joe: Boss...I know it's thin... but it might work.
Boss: Thin? ...Joe! - ...it's damn near invisible.
Boss: ...Joe - It really stinks down here....
Admin
I gotta hand it to you guys, I thought I had seen some nasty Excel stuff before, but NEVER have I seen someone try to do this. Why not just recursively call a single addition function for each column? Why wouldn't you just use Excel itself to add the columns? My head's gonna asplode if I think about it anymore! This makes no sense at all.