- 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
Soooo... this programmer is part of the "Local Variables Considered Harmful"-camp?
Admin
It's code like this that we can show to non-technical people and they will be in awe of our technical knowledge. It'll just look like gibberish to them, but we know enough about what's going on to make it seem like it's NOT gibberish to us.
But other than that, truly truly horrible. The goggles, they do nothing, or so I hear.
Admin
(Beavis/Butthead-style chuckle)
titS : array['A'..'U'] of string;
Admin
This really is bad. The fact that anyone said "It should be very clear" Is mind boggling. I can only image how awful the rest of the code looks. I would be a little more forgiving if the variable names were readable, but this just makes my head hurt.
Lets just hope they don't include files that used these global variables.
Admin
That's not code, that's art..
Admin
It boggles my mind that some people name variables well in one place (stop_key, wait_key) but so so badly in other places (wtf is a tol_lgd, or any of those other _lgd vars?)
Simply removing the vowels does NOT a good variable name make. Maybe this guy came from the DOS world and doesn't think the language supports variable names longer than 8 characters?
Admin
Ok, you win! I surrender! I am going to not pursue my career as a pascal -> atari programmer
Admin
{attenuation bezogen}
ahh, this makes it all clear now ?!?!
maybe if they named their variables as follows it would have been better
blah1
blah2
...
blah2000000
Admin
Perhaps "it's clear" simply because someone took the time to space things out into nice columns...
Admin
This made me yell "holy crap" at my monitor at work. That doesn't happen too often around here. Good job.
Admin
I'd prefer that naming scheme over the provided one....
Admin
That's got to be the nastiest Pascal code ever written, and we haven't even SEEN the implementation code yet.
Admin
This reminds me from an old code where, because some design constraints, a coleague had to declare global variables to report generation. So far, so good. The problem was that all (100+) reports shared the same variables. No need to say maintenance was incredible painful.
Thanks God he wasn't used to labels, exothic OO designs and code generation/snippets.
Admin
I can see nightmares after this. Maby i should stop reading tdwtf.
Admin
Should be, but is not.
<font size="3">The first variable name on the above line is very appropriate.
Sincerely,
Gene Wirchenko
</font></font>
Admin
I think you mean "wary", not "weary". Wary means you're cautious or suspicious about it. Weary means you're tired of it. Thus he was wary of the code beforehand and then weary of it after working with it for a while.
Admin
blinkblink*
Admin
Gag This seems like one of those programs that started small, grew incrementally, building internal pressure, and finally barfed all over its source code sneakers. Or something.
Don't bother trying to figure out every one. It looks like it's mostly platform specific nonsense anyway. Just try to come away with the general idea, and re-write the bugger. Better. Please.
Admin
I would like to point out the excellent use of commenting, which helps to clear up any possible misconceptions of what the variables are for.
Some of my faves: unused, abskfldr, and prbzn_slice.
I am so glad that it's got _slice in the name, I would never have known that the prbzn wasn't a full prbzn.
A long time ago, I read in a 6809 assembly programming manual that there is a special hell for people who code without comments...
This is a whole 'nother level...
Admin
You think that's bad? At least all the globals are in one easy-to-find spot, and Pascal is a very tightly typed language that doesn't allow you to cast from one type to another!
I've got C code I've had to work with here at work that not only has naming similar to this (or worse) with over 300 global variables (those are just the ones I'm aware of in the largest single area of declaration: I've not counted all the others!) and the original developer has a habit of not using unions at all, instead choosing to cast everything thrown into a variable into the particular types at will, and calling all the variables cast into that void * par....
I've seen something even worse than that in C++, though, in my more distant past, that makes both this example and what I see here at this employer seem reasonable by comparison for variable naming....
I'll leave it to the readers' imagination as to what could be worse than what I've stated I've got to look at currently, and imagine what I've seen in the past (I was very thankful I wasn't given the assignment to work with that code!)
Admin
Or in this case, weary of it after looking at it for a few seconds. ;)
Admin
I'll bet there are over 300 variables in that gawd-awful declaration, and like your project, this may in fact only be the largest single area of declaration...
I just love the fact that there is a global integer variable named 'i'.
Just think, you will never need to declare your loop variable again!!!
To avoid collisions where a loop that uses 'i' calls another function that loops with 'i', be sure to stack 'i' and restore it when your function exits. In fact, I bet there is a stack in that declaration somewhere, just for this!
Admin
Looks more like ASCII art than Pascal code
Admin
Of course the real WTF here is that he used magic numbers.
This:
Should properly be rewritten as
<font size="2">const SEVEN: int = 7;</font>
<font size="2">
</font>(my pascal syntax is rusty and I don't know if that would even compile, having a non-literal in an array declaration). BUT IT WOULD BE MUCH CLEANER.
Admin
Kids, what's the problem?
This is how things were done when I was young. You had to be a PROGRAMMER in order to write a program, not some mouse-pusher, gui-clicker pansy. And when you had to write a PROGRAM in quiche-eater Pascal you made at least sure that it was structured like FORTRAN. For men, not for quiche-eaters.
Admin
So, what you're saying is that we don't really have to have computer hacking skills. We just need to pretend we do....sweet.
Admin
Can you please base64 these kind of posts and put a little warning sign next to it
(like a 200x200 red alert animated gif?)
Thank you
-- be wearing two eye-patches for the next week at least
Admin
I don't know about that. But I guess to someone, anything could be considered art.
.jc
Admin
Oh my God, this can't be happening. This really isn't true. Nominate this guy for the white house.
Admin
There may even be a logic to the names, but if not documented, it is lost.
Hey! Some of those variable names are twelve characters long! He even used underscores to separate, uh, words. They are words, right?
Sincerely,Gene Wirchenko
Admin
We hear phrases like "It should work" or "It should be doing something" so often around here, "should" has been declared a swear word. We're thinking of having a "should jar", and putting 10c in everytime we hear that word...
Admin
Sooo, uh, what does the program do, Unkie Andy? It looks like it's taking several data files and tranforming one to the other, and that the data inside them, having variables with parts like pitch, dsp, and orch, must be related to sound or music. Porting this to a newer platform will prove interesting, I believe. Oh, and somehow there's a GUI involved, hence mouse_ok, mouse_hidden, mouse_forbidden. On the other hand, it could simply be an incantation to summon demons.
Admin
This looks pretty normal to me. In the real world, where all real programs are written in FORTRAN, we are used to hard copies of common block declarations that when printed (for documentation sake, to please the QA people) stand at approx 4 feet tall.
FORTRAN coders eat barbed wire
Admin
Bet this post was from the orignal coder of this crap. [<:o)]
Admin
Well, GG Allen used to dump on stage, spread it on himself, then throw it at the audience and THAT was considered art.
...
Considering that, it seems that GG Allen was probably the author of this code.
-This weeks one degree of separation brought to you by the letters w, t, f and the number 42 (represented by named constant EIGHT).
Admin
Somehow, these bowling scores came to my mind. But I don't think so.
Admin
Score: 3, Flamebait
Admin
I think we've found the first program that uses ROT13 to obfuscate the code....
Admin
And it probably uses ROT26 for data security...
Admin
<FONT face=Tahoma>must... pretend... i did NOT see this [+o(][+o(]</FONT>
Admin
Make it dollar!
Having heard the word too much, years ago, I came up with a definition for "should":
Present Tense: When you want to make a statement for which there is little logical support, but you still want to make the statement for reasons of pride, moral indignation, etc., use the present tense of "should". e.g. "This should work."
Past Tense: When the unknown or unaccounted-for factors sneak up behind you and kick you hard in the butt as you so richly deserve, use the past tense. Adopt a mournful expression and moan, "It should have worked."
Sincerely,
Gene Wirchenko
Admin
I remember coding for fun as a teenager back in the 80's. Everything I wrote wound up looking like that - and I got the impression from reading other people's code that was pretty typical. I think that was the reason I initially decided not to go into IT.
I was out of the loop for many years and ventured back in when Java was starting out. I was pleasantly surprised to learn that Java allowed you to escape that sort of pit.
Seeing this code brings back all sorts of memories both fond (Ultima III, Bard's Tale, Archon, Might and Magic) and unpleasant (Corey Hart, Duran Duran, Huey Lewis and the News). Probably because I was listening to the latter while playing the former.
Admin
Yeah, that's the point where you just have to give up on "porting" and start on "Rewriting from scratch". Use the program for a while, spec out what it does, and work from that spec rather than working from the original source code.
Admin
everything should be clear
That was not meant as a reassurance, it was the complete requirements doc for the porting project.
Admin
He must have heard the "Pascal forces you to write nice code" line once too often, and decided to prove it wrong.
Mike5
Admin
It's clear with the goggles on.
Admin
considering there was no OOP in the good old Pascal days, I don't see much problem with this code, but of course for these days "programmers" it hurts the eyes
Admin
Around here we like to say "in theory it will work..." The people in support threatened to put out a jar for just that reason.
Admin
Never coded for fun, just for dosh.
I have been coding in java for the last three years (after 15 years of FORTRAN 77, non of your girly FORTRAN 90 rubbish), and it just doesn't feel like "real" programming.
I just don't enjoy coding unless it's on a green screen monitor, and you have to count the indentation spaces.
Admin
This could have been expressed so much more elegant in the k language.
http://www.kx.com/a/k/examples/xml.k
(This will get you started: http://www.kuro5hin.org/?op=displaystory;sid=2002/11/14/22741/791 )