- 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
Comment1
Admin
comment2
Admin
There is NO WAY to tell what's going on with code like that. I'm assuming the programmer was either a) a retarded monkey, or b) never had to look at it again.
Now that I think of it there is a c) paid by the line!
Admin
WORD1 = "ARRAY" WORD2 = "B" WORD3 = "EVEN" WORD4 = "F" WORD5 = "HAD" WORD6 = "S" WORD7 = "THE" WORD8 = "V" WORD9 = "What" WORD10 = "!" WORD11 = " "
COMMENT = WORD9 + WORD11 + WORD7 + WORD11 + WORD4 + WORD11 + WORD3 + WORD11 + WORD8 + WORD2 + WORD11 + WORD5 + WORD11 + WORD1 + WORD6
Admin
Array[5:05am] = "No wonder noone else is up at this hour";
Admin
WTF?! Is that even legal?
Admin
Niiiice!
Admin
This comment is the best! I almost don't need my coffee this morning, almost.
Admin
Admin
Well, considering the only time COUNT* variables are read are on the last line, I don't think arrays are useful at all. friggin use a single COUNT!
Admin
What happened to Count16?
Admin
Ooh, a PICK Basic example! Had I known it was legal to get CodeSODs from PICK code I'd have been WTFing all over.
Admin
Using an array would make this code even WTFier
Admin
No, no, no! Arrays would simply not do! This something COMPELETELY DIFFERENT! Common! Array define all indexes from X to Y. Unless you're in Javascript or PHP where they are actually hashtables, so that's something COMPLETELY DIFFERENT again. But here - we don't need all the indexes! See - 16, 42, 47 and 50 through 98 are missing! Arrays would just not cut it!
Admin
Umm ok... so the given code is a grep on the word "count", so the code might make more sense in context and may even be commented, and I don't know what language this is, so I don't know what the right way would be...
Admin
d) Brilliant!
Admin
One! Two! Three! Ha! Ha! Ha! <Lightning bolt/thunder>
Admin
He's not missing arrays. He's missing a symbol table.
BTW: TeX has named string arrays but only 256 counters which are painful to manipulate.
Admin
Hm.. or the guy wrote a decompiler from ASM to whatever language is it, and that's the output. :)
Admin
<a rel="nofollow" href="javascript:WORD1 = "ARRAY"; WORD2 = "B"; WORD3 = "EVEN"; WORD4 = "F"; WORD5 = "HAD"; WORD6 = "S"; WORD7 = "THE"; WORD8 = "V"; WORD9 = "What"; WORD10 = "!"; WORD11 = " "; COMMENT = ""; COMMENT = WORD9 + WORD11 + WORD7 + WORD11 + WORD4 + WORD11 + WORD3 + WORD11 + WORD8 + WORD2 + WORD11 + WORD5 + WORD11 + WORD1 + WORD6; document.write(COMMENT);" target="_blank" title="javascript:WORD1 = "ARRAY"; WORD2 = "B"; WORD3 = "EVEN"; WORD4 = "F"; WORD5 = "HAD"; WORD6 = "S"; WORD7 = "THE"; WORD8 = "V"; WORD9 = "What"; WORD10 = "!"; WORD11 = " "; COMMENT = ""; COMMENT = WORD9 + WORD11 + WORD7 + WORD11 + WORD4 + WORD11 + WORD3 + WORD11 + WORD8 + WORD2 + WORD11 + WORD5 + WORD11 + WORD1 + WORD6; document.write(COMMENT);">javascript:WORD1 = "ARRAY"; WORD2 = "B"; WORD3 = "EVEN"; WORD4 = "F"; WORD5 = "HAD"; WORD6 = "S"; WORD7 = "THE"; WORD8 = "V"; WORD9 = "What"; WORD10 = "!"; WORD11 = " "; COMMENT = ""; COMMENT = WORD9 + WORD11 + WORD7 + WORD11 + WORD4 + WORD11 + WORD3 + WORD11 + WORD8 + WORD2 + WORD11 + WORD5 + WORD11 + WORD1 + WORD6; document.write(COMMENT);
Admin
this programmer should be shot.
Admin
What's with WORD10, you don't use that!
Admin
1 cent wager, this is Ingres/4GL code ?
Ingres 6.2
Once made a simple app to plan working hours for a field X type of a companies. Ruffly 40% of our customer base was still using ingres 6.2 because the license upgrade was very costly. So in order to make things easy, we couldnt use any "high tech" features like erm.. Arrays that where introduced in 6.4..
So the initial codebase was something like 15K lines ..
After ingres dropped their licensing fees and we where able to ship linux, rewrote the whole thing to 2k rows - just by eliminating if/else's into big loops =)
Admin
comments.h:10 warning: 'const char* WORD10' defined but not used
Admin
COMMENT = COMMENT + WORD10
Admin
This is stupid... why did you put .h when it's obvious its not a c language... did the absense of types and semicolons not do it for you?
Admin
I'm a noble : the Count of Comments!
Admin
OMG! I thought that was the best comment ever, but you Sir, were able to make it just more awesomely geek. Hands down for both of you.
Admin
Ingenious merely recognized it as being some Specification Language which is blindly parsed into C code. Warning messages obviously aren't generated until the generated code is compiled....you insensitive clod!
Admin
I once applied for a job with a bank that coded in PICK. Seeing this I'm glad I didn't get it!
Admin
COMMENT = WORD9 + WORD11 + WORD7 + WORD11 + WORD4 + WORD10 + WORD11 + WORD3 + WORD11 + WORD8 + WORD2 + WORD11 + WORD5 + WORD11 + WORD1 + WORD6 + WORD10
(Nevertheless, kudos to the OP! Well done! I particularly like the use of WORD6 -- that made me laugh)
Admin
If the language allows long strings, has capabilities to input/out numbers as text, and a substring function, then you can usually simulate arrays by defining a fixed field length and using a multiply to access the desired term.
It gets really tricky if you have only short strings, e.g. 255 characters, you need to come up with some very efficient packing mechanisms. Modulus is your friend.
If you're not pressed for performance, and the language has file I/O capabilities, you can simulate an array through file operations using fixed record lengths. This can be very inefficient if you have to iterate through [n - 1] records to get to the nth record.
This is basically the design philosophy of those old array-less languages, you read in a record from input, processed it, then printed to output. Back then you might have only a few K of memory, so arrays were a luxury. You designed such that you didn't use them.
Admin
I call shenanigans! I can't believe that the language had += implemented and didn't have arrays.
Admin
Admin
Admin
Admin
My current job I started out w/ BBx - where all variables are global and declarations are strictly optional. I thought that was bad. Old, crappy languages used for legacy software is no excuse to do stupid things.
If this is a legacy item, and that's how it had to be done, fine. If it has to be maintained, there is no reason to keep it. Throw that crap out and rewrite it using SOME best practice. ANY best practice. Something.
I just want to cry when I see things like that, though. What the hell is Count37 supposed to be? HUH? Who the hell can keep all that crap in short-term memory and actually do something useful? Huh? WTF? Just stupid.
Admin
<golf clap> well done, sir
Admin
Admin
This type of programming is only one step more advanced than developing the application on a bare metal Turing machine.
Admin
I have to say that when I first learned BASIC (back in the chisel-it-into-rock days) string arrays were not available on the HP2000. I remember how much in awe us "average" programmers were of the ones who were talented enough to actually alphabetize a list of words!
Admin
I once had to deal with code like this for a proprietary language that ran embedded code on a POS device.
What confounded my ordeal was the fact that code I inherited was written by a manager type...
Admin
Due to the brevity of today's story I found myself substituting some of the words to come up with another story with the same moral:
It's always a little frustrating when you're trying to seduce the most beautiful woman you can, but because of a limitation in your personality you have to roll up your sleeves and brute force it.
Admin
This is not about arrays at all. As others have insinuated,
COUNT[34] += NO.ITEMS
isn't much better. Second improvement:
COUNT[ITEMS] += NO.ITEMS
is starting to get there, but you still need to hardcode that 34 somewhere:
ITEMS=34
and we all know hardcoding is verboten. Soooo...
Just open a simple connection to a back end database where you can read ('ITEMS', 34) from an array definition table, and you're set!
Admin
Despite only being a list of search results it is easy to tell this is a horrific bit of code. At first I would have liked a bit more context but now I've thought about it I actually quite like the idea of only showing the results of a keyword search. Remember "Representative Line"? Maybe we could have some "Representative Grep" articles, highlighting how crap a piece of code is purely by showing the search results for a single keyword. Could be interesting.
Admin
Admin
Admin
Admin
Am I missing something... Arrays are not even needed; surely you could have replicated the code in the OP with just one variable?
Admin
peterke@host:~$ python Python 2.4.4 (#2, Jan 3 2008, 13:36:28) [GCC 4.2.3 20071123 (prerelease) (Debian 4.2.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.