Page 1 of 2

Programming hints everyone could use

Posted: 2005-11-23 02:16pm
by Yogi
Actually, I was kidding. Never use any of these practices in real life. An interesting and funny read though.

Posted: 2005-11-23 02:24pm
by Durandal
I read this yesterday. It's fucking brilliant.

Posted: 2005-11-23 03:07pm
by InnocentBystander
That lisp code made me cry.

Posted: 2005-11-23 03:20pm
by phongn
InnocentBystander wrote:That lisp code made me cry.
ROFLOL. Ever program in it?

Posted: 2005-11-23 03:36pm
by Yogi
InnocentBystander wrote:That lisp code made me cry.
I know the feeling. For my company to get hired I had to take an evaluation test where they gave us heavily obsfucated code and had us figure out the output value.

Posted: 2005-11-23 04:02pm
by NecronLord
This is just wicked...

Really now.

Posted: 2005-11-23 04:18pm
by Manus Celer Dei
Åccented Letters
Use accented characters on variable names. E.g.
typedef struct { int i; } ínt;
where the second ínt's í is actually i-acute. With only a simple text editor, it's nearly impossible to distinguish the slant of the accent mark.
Devious!

Posted: 2005-11-23 05:17pm
by Dooey Jo
I've seen it before, but it's still great. That LISP code is truly a piece of art!

Posted: 2005-11-23 05:30pm
by Durandal
The one that really had me cracking up was the statement

marypoppins = (superman + starship) / god;

Posted: 2005-11-23 05:36pm
by Tinkerbell
Obscure film references

Use constant names like LancelotsFavouriteColour instead of blue and assign it hex value of $0204FB. The color looks identical to pure blue on the screen, and a maintenance programmer would have to work out 0204FB (or use some graphic tool) to know what it looks like. Only someone intimately familiar with Monty Python and the Holy Grail would know that Lancelot's favorite color was blue. If a maintenance programmer can't quote entire Monty Python movies from memory, he or she has no business being a programmer.

That made me happy

Posted: 2005-11-23 05:57pm
by SirNitram
Tehy froogt my faovirte tirck: MIT dsicovreed taht if the frist and lsat lteters are rgiht, and the lnegth is crorect, you wlil raed it.

In other words, if every one of your functions is mispelt under those rules, people will automatically correct the spellings and break things.

Posted: 2005-11-23 06:26pm
by InnocentBystander
phongn wrote:
InnocentBystander wrote:That lisp code made me cry.
ROFLOL. Ever program in it?
Some DrScheme for a couple classes, it looks to be the same, and I absolutely hate it. Of course, we never acutually used it for anything useful...

Posted: 2005-11-23 07:16pm
by Darth Paul
A classic. You may also enjoy http://thedailywtf.com/.

The sad thing is, after maintaining some (rather expensive) legacy code for awhile, I have seen way too many of these, uh, techniques employed for real.

I don't need to test my programs. I have an error-correcting modem.

Posted: 2005-11-23 07:43pm
by Admiral Valdemar
Oh, I wish I had this when I was doing my final year projects in Pascal and VB. The project was shit, but hey, if I can make it as hard and interesting as possible to read in source, I don't care.

"It was hard to code, so it should be hard to read." I never did put comments in.

Posted: 2005-11-25 12:18pm
by Faqa
You used a combo of VB and Pascal? You used VB for anything besides a GUI?

[CluelessBlond]Ewwwwwwwwwwwwwwwww........................[/Clueless Blond]

Otherwise, I'm suddenly grateful the code I have to decipher is only lazy, not malicious. Force these guys to use Perl for a month, they'd learn how to document code.... *grumbles*

Posted: 2005-11-25 12:23pm
by Admiral Valdemar
Nah, two separate projects that. Pascal 7 was for one thing, VB for another. The Pascal project I forget what it was, but VB was for an automated database.

Posted: 2005-11-25 12:27pm
by Faqa
Yeah, but still....

What part of "VB is for GUI's" did your instructors not understand? Or did they not know how to link em? It's the reason VB.NET is utterly and completely useless(VS2005 already gives you GUI capabilities for C#).

Oi, never mind my snobbery. I just dislike VB..... :wink:

Posted: 2005-11-25 12:35pm
by Admiral Valdemar
I believe you could use C++ or Perl or Python or any other language you wanted with VB if you were well versed in them. Since I wasn't and nor did I really care for my second year project which was bullshit, I just used VB for that. It actually worked somewhat, just, er, not as in the brief.

Posted: 2005-11-25 01:18pm
by Faqa
It actually worked somewhat, just, er, not as in the brief.
It's not a bug, it's a feature, dammit! :D

Posted: 2005-11-25 01:23pm
by Ace Pace
Faqa wrote:
It actually worked somewhat, just, er, not as in the brief.
It's not a bug, it's a feature, dammit! :D
Is that what you tell those above you when your program fucks up? ;)

That list shall be put into operation as soon as I figure out how to make it work ;)

Posted: 2005-11-25 01:31pm
by Faqa
Hey, if they can't appreciate pondering patience while waiting for a page to get through redundant server checks, they're not worth my time 8)

Most of that list is C++ in-jokes, Ace. Your course doesn't cover that unless I'm mistaken.

Posted: 2005-11-25 02:56pm
by Braedley
There's a reason why my high school CS teacher had rules to contradict these. Like no goto, break, or global, among other rules.

Gratuitous use of goto in a tightly packed program is best (hell even one, very obscure goto in the middle of the progam is good). Add or remove just one line in a program can royaly fuck it over. Using labels reduces 99% of this, so the moral of the story is never use labels with any goto statement.

Posted: 2005-11-25 03:45pm
by Braedley
We did some relatively complex stuff, but we were always encouraged to find ways around using break (and in most loops, using the test variable is sufficient). The switch statement was an exception as it's very difficult to use without break sometimes.

Posted: 2005-11-26 12:19am
by Dennis Toy
I heard that VB was actually used for Human Genome Project. The super-computers ran using VB codes.

Man oh man do i HATE Java! that shit is so hard and needlessly complex that i totally gave up trying to program in it.

Posted: 2005-11-26 12:32am
by Xenophobe3691
Dennis Toy wrote:I heard that VB was actually used for Human Genome Project. The super-computers ran using VB codes.

Man oh man do i HATE Java! that shit is so hard and needlessly complex that i totally gave up trying to program in it.
Dammit man, you're telling me! I got my program all nice and set, only to discover that there's no exponent operator in that language.

And it doesn't make creating one easy, as well. God Damn Java...