Comment On A Man's Array

It's always a little frustrating when you're trying to write the most beautiful code you can, but because of a limitation in the programming language you have to roll up your sleeves and brute force it. As programming technologies mature, I find this to be rarer and rarer. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: A Man's Array

2009-02-25 08:04 • by monkeyPushButton (unregistered)
Comment1

Re: A Man's Array

2009-02-25 08:04 • by monkeyPushButton (unregistered)
comment2

Re: A Man's Array

2009-02-25 08:04 • by Addison (unregistered)
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!

Re: A Man's Array

2009-02-25 08:04 • by Skizz
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

Re: A Man's Array

2009-02-25 08:05 • by First? :) (unregistered)
Array[5:05am] = "No wonder noone else is up at this hour";

Re: A Man's Array

2009-02-25 08:21 • by Steenbergh (unregistered)
WTF?! Is that even legal?

Re: A Man's Array

2009-02-25 08:24 • by snoofle
245756 in reply to 245752
Skizz:
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

*spits coffee*

Niiiice!

Re: A Man's Array

2009-02-25 08:27 • by ben (unregistered)
245759 in reply to 245752
This comment is the best! I almost don't need my coffee this morning, almost.

Re: A Man's Array

2009-02-25 08:28 • by ben (unregistered)
245760 in reply to 245752

Re: A Man's Array
2009-02-25 08:04 • by Skizz
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

This comment is the best! I almost don't need my coffee this morning, almost.

Re: A Man's Array

2009-02-25 08:32 • by barbie (unregistered)
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!

Re: A Man's Array

2009-02-25 08:39 • by James (unregistered)
What happened to Count16?

Re: A Man's Array

2009-02-25 08:41 • by Techzoid (unregistered)
Ooh, a PICK Basic example! Had I known it was legal to get CodeSODs from PICK code I'd have been WTFing all over.

Re: A Man's Array

2009-02-25 08:41 • by FDF (unregistered)
Using an array would make this code even WTFier

Re: A Man's Array

2009-02-25 08:49 • by Vilx- (unregistered)
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!

Re: A Man's Array

2009-02-25 09:11 • by jonnyq
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...

Re: A Man's Array

2009-02-25 09:12 • by ih8u (unregistered)
245772 in reply to 245751
Addison:
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!


d) Brilliant!

Re: A Man's Array

2009-02-25 09:16 • by AndyL (unregistered)
One! Two! Three! Ha! Ha! Ha! <Lightning bolt/thunder>

Count Drakula

2009-02-25 09:18 • by Tzafrir Cohen (unregistered)
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.

Re: A Man's Array

2009-02-25 09:19 • by Tigio (unregistered)
Hm.. or the guy wrote a decompiler from ASM to whatever language is it, and that's the output. :)

Re: A Man's Array

2009-02-25 09:23 • by DaveK
245776 in reply to 245752
Skizz:
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
It's funny you should say that, since I decoded your message by pasting it into my broswer's address bar.

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

Re: A Man's Array

2009-02-25 09:26 • by pitchingchris
this programmer should be shot.

Re: A Man's Array

2009-02-25 09:39 • by pscs
245780 in reply to 245752
Skizz:
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


What's with WORD10, you don't use that!

Re: A Man's Array

2009-02-25 09:42 • by Jani Mikkonen (unregistered)
1 cent wager, this is Ingres/4GL code ?

Ingres 6.2
- No arrays
- No Globals
- No shit!

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

Re: A Man's Array

2009-02-25 09:42 • by ingenious (unregistered)
245783 in reply to 245752
comments.h:10 warning: 'const char* WORD10' defined but not
used

Re: A Man's Array

2009-02-25 09:42 • by Inno (unregistered)
245784 in reply to 245752
Skizz:
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


COMMENT = COMMENT + WORD10

Re: A Man's Array

2009-02-25 09:45 • by pitchingchris
245785 in reply to 245783
ingenious:
comments.h:10 warning: 'const char* WORD10' defined but not
used


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?

Re: A Man's Array

2009-02-25 09:57 • by mauhiz (unregistered)
I'm a noble : the Count of Comments!

Re: A Man's Array

2009-02-25 09:58 • by ubersoldat
245787 in reply to 245776
DaveK:
Skizz:
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
It's funny you should say that, since I decoded your message by pasting it into my broswer's address bar.

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


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.

Re: A Man's Array

2009-02-25 09:58 • by Anonymous Coward (unregistered)
245788 in reply to 245785
pitchingchris:
ingenious:
comments.h:10 warning: 'const char* WORD10' defined but not
used


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?


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!

Re: A Man's Array

2009-02-25 10:00 • by rpjs (unregistered)
245789 in reply to 245765
I once applied for a job with a bank that coded in PICK. Seeing this I'm glad I didn't get it!

Re: A Man's Array

2009-02-25 10:01 • by nickc (unregistered)
245790 in reply to 245784
Inno:
Skizz:
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


COMMENT = COMMENT + WORD10

Sure, that's the quick and dirty fix. But the client probably wanted:

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)

Re: A Man's Array

2009-02-25 10:08 • by Buddy (unregistered)
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.

Re: A Man's Array

2009-02-25 10:11 • by Scott (unregistered)
I call shenanigans! I can't believe that the language had += implemented and didn't have arrays.

Re: A Man's Array

2009-02-25 10:15 • by DaveK
245797 in reply to 245790
nickc:
Inno:
Skizz:
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


COMMENT = COMMENT + WORD10

Sure, that's the quick and dirty fix. But the client probably wanted:

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)
INB4 someone suggests making a compression scheme out of this...

Re: A Man's Array

2009-02-25 10:16 • by DaveK
245798 in reply to 245791
Buddy:
[ ... ] so arrays were a luxury. [ ... ]
InB4 Monty Python sketch.

Re: A Man's Array

2009-02-25 10:18 • by DaveK
245799 in reply to 245798
DaveK:
Buddy:
[ ... ] so arrays were a luxury. [ ... ]
InB4 Monty Python sketch.
A verbose comment to anticipatorily-pre-empt any potential future comment arising that might suggest I should shut up with the InB4 stuff now. I will, promise!

Re: A Man's Array

2009-02-25 10:20 • by jimlangrunner
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.

Re: A Man's Array

2009-02-25 10:23 • by campkev
245801 in reply to 245776
DaveK:
Skizz:
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
It's funny you should say that, since I decoded your message by pasting it into my broswer's address bar.

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


<golf clap> well done, sir

Re: A Man's Array

2009-02-25 10:24 • by DaveK
245802 in reply to 245800
jimlangrunner:
I just want to cry when I see things like that, though. What the hell is Count37 supposed to be?
Well, duh. It's the thirty-seventh count. I would have thought that was obvious. *rimshot*

Re: A Man's Array

2009-02-25 10:28 • by iToad (unregistered)
This type of programming is only one step more advanced than developing the application on a bare metal Turing machine.

Re: A Man's Array

2009-02-25 10:33 • by n9ds
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!

Re: A Man's Array

2009-02-25 10:37 • by lyates
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...

Re: A Man's Array of options

2009-02-25 10:43 • by Time Zoned (unregistered)
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.

Re: A Man's Array

2009-02-25 10:47 • by General Failure (unregistered)
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!

Re: A Man's Array

2009-02-25 10:52 • by Anonymous (unregistered)
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.

Re: A Man's Array

2009-02-25 11:01 • by snoofle
245815 in reply to 245787
ubersoldat:
DaveK:
Skizz:
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
It's funny you should say that, since I decoded your message by pasting it into my broswer's address bar.

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


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.
Seconded! You guys rock!

Re: A Man's Array

2009-02-25 11:18 • by DOA
245818 in reply to 245815
snoofle:
ubersoldat:
DaveK:
Skizz:
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
It's funny you should say that, since I decoded your message by pasting it into my broswer's address bar.

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


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.
Seconded! You guys rock!
I just like Davek's post. It's always nice when someone's willing to waste their time so you don't have to.

Re: A Man's Array

2009-02-25 11:31 • by pjt33
245819 in reply to 245761
barbie:
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!

That's precisely what I was going to say. Blue box for Barbie's post, please!

Re: A Man's Array

2009-02-25 11:34 • by Chris (unregistered)
Am I missing something... Arrays are not even needed; surely you could have replicated the code in the OP with just one variable?

Re: A Man's Array

2009-02-25 11:39 • by Peterke - pure copy paste (unregistered)
245830 in reply to 245776
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.
>>> 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
>>> COMMENT
'What THE F EVEN VB HAD ARRAYS'
>>>
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment