- 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
...wow.
Admin
NFW?
Admin
That's weird - it's all I could say too: "Wow..."
Admin
Wow.
Who typed it all in the first time? The next patient over in the Carpal Tunnel Ward?
Admin
Easy, just rewrite it in VB with optional parameters.
Then start the long hard road to building it right.
Jonathan
Admin
Or I guess you could just use param arrays.
Admin
FIST!
Ooooh my good, that's just so exceptionally horrendous I can't feel the need to run manically around on the street screaming! Didn't they hear of the "params" keyword? And what even made them think of such a function in the first place?!?
Admin
<font color="#008000" face="Courier New" size="2">* 20060718 - Mike - v3.0 - Added support for adding columns aaa to zzz.
*/</font>
Admin
Admin
I can only see one possible solution:
Step one: rm -fr /
Step two: "Hey, boss... I quit"
Admin
"The goggles..."
Admin
Fortunately there are no triple-letter columns in Excel (at least for now). This puts a natural limit of sorts on this.
Admin
Admin
This is completely insane! I would say that I would have to take over design, or quit.
Admin
The "right" way to do it (in C, C++, or Objective C) would be make it variadic. For ten lines you could fix everything.
Admin
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).
Admin
Aaaaaaiiiiiiiiiiiiiiiiiiiiiiiieeeeeeeeeeeeeeeeeeeeeeeeegggggggggggggggghhhhhhhhhhhhhhhhh !
Wait for it - add additional overloads to add all permutations of cells for all permutations of multiple rows
Admin
I sure hope that's a joke ... the "right" way to do it (in *any* language that supports COM) is to pass in a single Range object and to enumerate the Cells and add them up ... or a worksheet object and a row # ... Or, just use a simple Excel function to do the math !! I hear that the latest versions of Excel support formulas!
Admin
seems like it'd be a trivial matter to write a perl script to generate all the functions you need.
i'd do that, and then quit.
Admin
So, what's everybody's favorite part of this? Mine is,
No. No it does not. It adds up 600+ integers typed in by another hamsterwheel employee. It does nothing with any Excel file.Admin
They appear to just be storing column values as ints. Why not just chop this bad boy down and use a hashtable? Iterate it in the method and handle things accordingly. It's still one ugly mofo, but that would be a step in the right direction.
Admin
Or, just use the Excel object model ???? Or would that be too easy?
Admin
I personally love the reserved word escaping:
_as
_do
_is
Thankfully pi isn't one--it's System.Math.PI
And params arrays are probably the best bet for fixing the original problem, but that's just a stopgap. I can't really think of a better way because I haven't done Excel Interop (and now I just jinxed myself, sigh)
Admin
This code is NSFW.
Admin
3"Hm, I wonder what is that 'array' thing I keep hearing about..."
By the way, I think this is the first time when the cries about something (this thing doesn't even deserve to be called 'code') being generated might be true 3
Admin
Admin
When I saw this, my response was, literally,
D:
hint: (tilt your head 90 degrees clockwise)Admin
I totally agree with this. You can't trust Excel to calculate the numbers of a single row... What does Excel even know about math! Better to do it yourself...
Admin
I'd say from my experience that in C# you can get a DataTable from excel file in umm 3 lines and then add it up in 2 more lines :) Thus cutting over 100 lines of this craptastic solution to mere 5 lines :)
Admin
And thus, you have created your own WTF. Congratulations!
Admin
Oh my... GOD... it's BURNING... ...my... my EYES... STUMBLE ... it's SO... oh MY... AAAAHHHGGGHHH... i can't... no... this is... this is not... real... no... NO... NOOO..VOMITONFLOOR ... heavybreathing* CRY
Admin
Um. Wow. Dear gods, why would anyone write a function to do this that requires each value to be a parameter? Can't they just pass the row they want and iterate through, accumulating the total, and substituting a zero when there's a null/empty-string value?
Whoever thought this was the right approach should be drawn and quartered.
Admin
int _as
int _do
At least he has avoided keyword ambiguity!
Admin
I've been reading this site for over a year now and that might be the most appalling wtf I have seen.
Admin
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!
Admin
* 20060710 - BSR - v*.0 - So tierd of copy-paste-edit for the parameters that I'm not going to update the comment any more.
Admin
Unless I'm very much mistaken, Excel has a SUM(...) function - surely anyone who could write this would know that...
Admin
The substitue nulls thing would work, assuming there were no non-null cells they wanted to exclude.
Admin
Honestly, this is the first WTF that I believe to be fake.
Admin
Maybe they were clever enough to make a copy of the "int aa" through "int az" block, then instructing their text editor to replace "int a" with "int b"? All that computing power sitting on your desk must be good for something, after all...
Admin
<FONT face="Courier New">WorksheetFunction.Sum(Range("A1:Z99"))</FONT>
Admin
Okay, I'm not a 100% sure about this (only 99), but isn't there a second WTF here? The method takes around seven hundred 32-bit integers and is supposed to return their sum as 64-bit long, but it actually does 32-bit integer addition all the way, thereby potentially discarding the most significant bits?!?
Admin
why not use
excel.worksheetfunction.sum()
Admin
So how many lines of code did you write today? Minus 95?
So is this "a function to quit for," or "a function to get yourself fired for" on account of extremely unsactisfactory output (in terms of lines of code)?
Admin
<FONT face=Arial size=2>Amazing people have not discovered the simplicity of arrays as parameters...</FONT>
<FONT face="Courier New"><FONT color=#008000><FONT size=2>public long addUpAllExcelColumns(int[] Columns)
{
//do whatever
}</FONT></FONT></FONT>
<FONT face=Arial size=2>-jeff</FONT>
Admin
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?
Admin
Admin
Admin
c# actually has something called a "params" array.. using it for this would be an abuse of its design (as if the current design isn't already), but it might make maintenance easier
Admin
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!