Click to See Complete Forum and Search --> : wit in code


justsomeone
09-29-2005, 05:25 AM
Have you ever found yourself maintaining the code of a long-gone programmer, trying to work out what the heck they were thinking about, only to find the situation eased by the use of some humour in the code which helped make things clearer? And I don't just mean in the code...

A lifetime ago, I was working in a company which developed alot of mainframe applications for internal use. This was a shoestring operation some of the time, and a lot of systems were designed to be reasonably robust, but not bulletproof. If something bad happened, the techies could deal with it. Bad things happened reasonably often, and needed some manual intervention to sort it out. While you were sorting it out, it was vital to prevent the user from making things worse by attempting to work around the problem. If somoene ran into a problem, you wanted to stop them from going any further until you got the issue resolved.

This was in the days of mainframes and dumb terminals. Each user had a single session, and couldn't just pop open a new window to log in again. The company philosophy was that when something bad happened, you gave the user as much diagnostic info as you could and then dropped into an infinite loop which kept their session busy. When you had resolved the problem, you killed the session and they logged in again.

I don't want to start a debate on the merits of this approach - like I said, it was a long time ago and far away. I just found the relevant code quite witty. In PHP it might look something like this:


define ("DOOMSDAY", "FALSE");

while (!DOOMSDAY){
// do nothing
}


except this wasn't PHP, and the while loop above became

REPEAT UNTIL DOOMSDAY

which always made me smile.

It became better when some wag surreptitiously introduced a new standard of

REPEAT UNTIL PAYDAY


Any other examples of amusing code, or am I just revealing myself to be a complete geek here?

Weedpacket
09-29-2005, 06:03 AM
Both, I think :D

Here's a Wiki page (http://c2.com/cgi/wiki?FunnyThingsSeenInSourceCodeAndDocumentation) I came across that collects things like this. Makes me wish I'd kept a collection of some of the comments and idioms I've seen. Maybe I'll start now.

justsomeone
09-29-2005, 10:09 AM
Entertaining stuff. Thanks :D

Elizabeth
09-29-2005, 10:39 AM
Both, I think :D

Here's a Wiki page (http://c2.com/cgi/wiki?FunnyThingsSeenInSourceCodeAndDocumentation) I came across that collects things like this. Makes me wish I'd kept a collection of some of the comments and idioms I've seen. Maybe I'll start now.
Seriously funny. And so much more creative than the occasional use of 'loser' that I put in my code ("You're such a loser, you can't even connect to the database!") Of course, that's only in my own stuff, not for clients-- I don't think they would find that very funny. :)

dalecosp
09-29-2005, 04:46 PM
Well, I dunno if I mentioned it before, but BSD's shutdown(8) is a little crazy./* declaration, line 101 */
void die_you_gravy_sucking_pig_dog __P((void));
/* called in line 266 */
for (;; ++tp) {
timewarn(tp->timeleft);
if (!logged && tp->timeleft <= NOLOG_TIME) {
logged = 1;
nolog();
}
(void)sleep((u_int)tp->timetowait);
if (!tp->timeleft)
break;
}
die_you_gravy_sucking_pig_dog();
}
/* and defined thus: */
void
die_you_gravy_sucking_pig_dog()
{
char *empty_environ[] = { NULL };
syslog(LOG_NOTICE, "%s by %s: %s",
doreboot ? "reboot" : dohalt ? "halt" : dopower ? "power-down" :
"shutdown", whom, mbuf);
(void)sleep(2);
(void)printf("\r\nSystem shutdown time has arrived\007\007\r\n");
if (killflg) {
(void)printf("\rbut you'll have to do it yourself\r\n");
exit(0);
} I think you can learn a lot about the philosophy of the BSD's in that last printf(). ;)

Recently, I gave my "girl friday" permission to access the check posting area of our local intranet, so she could reconcile bank statements. When coding it, I'd intended it just for me. I had a pretty good chuckle one day when she left a field blank, hit submit, and then stopped short at the response "Fill in the form, stupid! 8-("

'Twas a good thing I was being relatively nice to myself on the day I wrote that.... :D

goldbug
09-29-2005, 07:56 PM
Seriously funny. And so much more creative than the occasional use of 'loser' that I put in my code ("You're such a loser, you can't even connect to the database!") Of course, that's only in my own stuff, not for clients-- I don't think they would find that very funny. :)
... and published books :D

Regarding "odd" code: I've been finding myself doing it more and more lately, but usually only in prototyping--helps make it even more enjoyable for myself. Lately, I've been naming functions like "serious" functions might be named, but typing out an implied pirate or stereotypical 1930's gangster voice (function get_results_seeee() {} )

Elizabeth
09-29-2005, 09:11 PM
...but typing out an implied pirate or stereotypical 1930's gangster voice (function get_results_seeee() {} )That's hilarious! Perhaps I'll turn to the good ol' Dialectizer (http://rinkworks.com/dialect/) for assistance for my next project. (If I used the "redneck" one it might actually help anyone using my code afterward, given our current location)

Weedpacket
09-29-2005, 11:29 PM
#ifdef YES_I_KNOW_THIS_IS_DANGEROUS_BUT_I_WANT_TO_DO_IT_ANYWAY
....


"Whoops; I must have set it by accident...."

dalecosp
09-29-2005, 11:48 PM
<--- suppresses much chuckling....