• Micael Baerens (unregistered)

    First!

  • (cs) in reply to nsimeonov
    nsimeonov:

    Jeff S:
    nsimeonov:
    Writing a small program to generate the functions won't be hard ... and in 10 min you're ready with so much source code... it's a whole other thema that the design seems to be f***ed up from the beginning... why should one have a function to sum up integers (really, why only integers?) when it's easier to type "+" instead of calling a function?


    You need to step back further ... the issue is not that a function was written to sum integers ... it is that someone is writing code to convert all of these excel values to integers, one by one, so that they can call this function! 

    using code generation to create overloads and/or using an array as a parameter does *not* solve the issue here.   replacing the function call with a huge expression using + with 256 numbers is not the solution and it is no better!

    It is amazing how many people are not getting this ....

    I think everyone realizes it. It was a black humor on my side to "shine" by writing a code generator (and hide it from the boss) so you can do a 3-day work in 10 minutes :)

    I believe the original programmer was one of those kids, who put a square block into a round hole using a big hammer. I had a couple of guys like this working for me and I was always amazed how they never stop for a moment to think if there's something really wrong in the approach, but instead they keep working and working until something terrible like this comes to me (proudly presenting their work finally done). Tell me what's the best approach to explain how wrong this is. I usually try a couple of times politely but after explaining about similar repetetive code over 3 times I can't hold myself and there was a lady that pissed me so bad that I yelled at her for about 30 minutes... wrong but... oh well...



    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.
  • (cs) in reply to Micael Baerens

    Anonymous:
    This function is so stupid that it surprisingly allows a magical solution! Create another function with just one parameter and tell the other programmers to use the symbol "+" instead of "," as parameter separator... and return the valued passed in. Done! Your bosses will be amazed!

    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.

  • captcha=wtf (unregistered) in reply to Martijn
    Anonymous:

    There must be atleast as many ways to do this better as there are arguments in the function call.

    I especially like how this remind me of a WTF of a few days ago which read somewhat like "long add(int a, int b) { return a + b; }". This WTF is roughly 300 times worse.

     

    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.

  • (cs)

    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!

  • David Jessop (unregistered) in reply to Doug
    Anonymous:
    Alex Papadimoulis:

    ...create overloads for the following function so that developers don't need use zeros if they don't need all of the 600+ parameters ...




    I thought Excel was restricted to 256 columns (IV, or 2^8) and 65536 rows (or 2^16) per workbook.  I'm not sure what the workbook limitation is.

    At least that's the way it is in Excel 2002, from what I can tell.

    Would that be the real WTF, perchance?


    doug.

    CAPTCHA == 'hacker'
    # Sweet!

    But just wait until Excel 12 arrives with 16000 (well, 2 ^14) rows.  I'd love to watch someone make that edit!

    David

  • (cs) in reply to BAReFOOt

    ...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

  • (cs) in reply to Mikademus

    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."

  • (cs) in reply to John Bigboote

    John Bigboote:
    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."

    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*

  • Mark H (unregistered) in reply to apparition
    apparition:

    Aaaaaaiiiiiiiiiiiiiiiiiiiiiiiieeeeeeeeeeeeeeeeeeeeeeeeegggggggggggggggghhhhhhhhhhhhhhhhh !

    Wait for it - add additional overloads to add all permutations of cells for all permutations of multiple rows



    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.
  • (cs) in reply to seymore15074
    seymore15074:

    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*



    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.
  • Kooky Koder (unregistered) in reply to Kemayo

    you forgot the required <sarcasm> tags

  • (cs) in reply to seymore15074

    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.

  • John (unregistered)

    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);}

  • Nobody (unregistered) in reply to gushie

        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>

  • Wally T Franklin (unregistered) in reply to radiantmatrix

    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

  • (cs) in reply to neven
    neven:
    So, what's everybody's favorite part of this? Mine is,

    /* adds up all the column values for a specific row from an excel file.

    No. No it does not. It adds up 600+ integers typed in by another hamsterwheel employee. It does nothing with any Excel file.


    That's this company's version of encapsulation.
  • (cs) in reply to Sean
    Sean:

    That's this company's version of encapsulation.


    I dub this technique "encrapsulation."
  • Joshua Volz (unregistered)

    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?

  • Anony (unregistered) in reply to Volmarias

    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!)

  • (cs)

    Probably not java, you cannot have more than 255 parameters

    http://javaspecialists.co.za/archive/newsletter.do?issue=059&locale=en_US

  • (cs) in reply to GoatCheez
    GoatCheez:
    IITIKWGO == If I think I know what's going on...
    LOL. You used your acronym only once in the entire post and then ended up typing the whole thing out anyway. That's like zipping a 2-byte file. :P
  • (cs) in reply to Maarten
    Anonymous:

    In a next release, they could introduce an optimized version of this function that only adds the specified rows from "first" to "last". Utilizing the "for-switch paradigm", this would result in:

    <FONT face="Courier New">public long addUpAllExcelColumns(int first, int last)
    {
    int sum = 0;</FONT>

    <FONT face="Courier New">for (int row = first; row <= last; row++) {

    </FONT>

    <FONT face="Courier New">   Select Case row
        Case 1
       sum += WorksheetFunction.Sum(Range("1:1"));
        Case 2
       sum += WorksheetFunction.Sum(Range("2:2"));
        Case 3
       sum += WorksheetFunction.Sum(Range("3:3"));
     
        /* Snip 131068 lines. */
       
        Case 65535
       sum += WorksheetFunction.Sum(Range("65535:65535"));
        Case 65536
       sum += WorksheetFunction.Sum(Range("65536:65536"));
        Else Case
       sum += 'brillant'
       End Select
    }
    }</FONT>

    <FONT face="Courier New">return sum;

    </FONT>

    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?

  • Me (unregistered)

    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...

  • Azi (unregistered) in reply to Me

    It'll be nice to provide us a function call as well.

  • Urizen (unregistered)

    for shure ^^

    this MUST be a coke !?!

    ... no one with at least 5 minutes of  programming experience would create a method like this ...

  • Dwonis (unregistered) in reply to Asztal
    Anonymous:
    Well, obviously it's to allow for changes in the future! What if, for example, they wanted to change addUpAllExcelColumns

    to take the standard deviation of them?



    Mike should make the overloaded functions "add" everything over GF(2^32).

  • (cs)

    I can't believe that, are you kidding on us?

    Friedrich

  • jdoege (unregistered) in reply to JBL

    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.

  • (cs) in reply to mercurysquad
    mercurysquad:
    GoatCheez:
    IITIKWGO == If I think I know what's going on...
    LOL. You used your acronym only once in the entire post and then ended up typing the whole thing out anyway. That's like zipping a 2-byte file. :P
    .

    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 ;-)
  • Still coding in C++ (unregistered) in reply to Richard Johnson
    Anonymous:

    I aint no Excel junkie, and thought of the "sum()" thing too.  In our shining wtf, we have a clue what happens when some user puts a datae or string into a cell -- the whole thing blows up.  What happens in Excel (isung a sum()) when someone drops in anything at all other than an int? 

    --

    RJ

     

    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.

     

  • Jeremy (unregistered) in reply to Jeff S

    Jeff S:
    A classic.  Wow.  speechless.  A WTF on so many levels. 

    What is really funny is that in order to call this function, someone must have learned how to use the Excel object model to get the values from the worksheet .... but aparently they learned only the absolute minimum to get the job done  (probably the Worksheet.Cells(x,y) method which can return a single-cell Range from a row/column).  

    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....

     

  • anonny (unregistered) in reply to Jeremy
    Anonymous:
    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>

    It all boils down to memory waste in a wide variety of forms -- instructions, data, and stack.  Which may not seem important when everyone and their dog has multiple gigabytes of RAM, but really will make it run slower because the CPU will spend more time shuffling useless wasted memory back and forth from cache to RAM.

  • Anthony (unregistered) in reply to mol

    XFD is the last column in Excel 2007.... but yeah, ouch, doh!

  • joe.edwards (unregistered)

    public long addUpAllExcelColumns( params int a[] ) {
       long retval = 0;
       foreach( int i in a ) retval += i;
       return retval;
    }

    // Voila.

  • Justin Hart (unregistered) in reply to JBL
    JBL:
    Wow.

    Who typed it all in the first time? The next patient over in the Carpal Tunnel Ward?


    My guess would be that the original programmer wrote a script to write those functions.
  • Nick Manley (unregistered)

    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.

  • DONKEY (unregistered) in reply to mol

    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

  • TC (unregistered)

    The real WTF is that 1+2+3+4 is shorter than addExcelColumns(1,2,3,4).

    captcha: captcha

  • metallic (unregistered) in reply to Dave

    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.

  • Timwi (unregistered)

    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.)

  • (cs) in reply to Micael Baerens
    Micael Baerens:
    First!

    Nice VICModem you have there  ;-)
  • tener (unregistered) in reply to Uncoolperson

    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>

  • (cs)

    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....

  • (cs)

    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. 

Leave a comment on “A Function to Quit For ”

Log In or post as a guest

Replying to comment #:

« Return to Article