Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

[P]
Code Humor Challenge

By Milo Minderbender in Technology
Tue Jun 01, 2004 at 01:21:10 PM EST
Tags: Humour (all tags)
Humour

The goal is to get a humorous piece of code into a production environment. Any kind of humor is acceptable...anything that might make a future developer smile. The code must actually be used by the application.


Qualifying Examples I've Seen

StaleBreadcrumbException

I've only ever truly succeeded once. One of my previous employers had a class called Breadcrumbs to maintain a navigation trail at the top of the web page. They also had a StaleRecordException for when the user tried to modify a database record that another user had modified since the record was loaded. The navigation breadcrumbs had a certain lifetime before they expired. If you tried to read the breadcrumb information after they had expired, I added a StaleBreadcrumbException.

Royal Food Taster

This is the only open source example that I know of. I won't get into how the technology works, but in the Prevayler project, to maintain data consistency, there is a need to run each transaction on a copy of the system first to make sure it succeeds. This is done by instantiating a RoyalFoodTaster.

Close, but no cigar

McNugget

One of my previous employers had, for historical reasons, the requirement that all class names be prefixed with "Mc" (McUser, McCheckbox, etc.). I created the class McNugget, complete with methods like McNugget.dip(McNugget.BBQ_SAUCE). Unfortunately, I was unable to incorporate this into the telecommunications billing software the company was writing. It did, however, stay in the version control system long after I left the company.

The Last Resort

I worked on some software for a travel agency once with classes like Booking and Hotel and Resort. I did my best to find an algorithmic requirement to get the last object from a list of resorts, but I never could incorporate a getLastResort() or isLastResort() method.

Honorable Mentions

I include these because they are funny. However, because the humor is entirely based on complete programmer ineptitude and not on a clever pun, they really don't qualify for the Code Humor Challenge.

Integer Wrapper

The following is actually in production use in a nationwide travel agency chain. Every computer in every franchise location is running this code. Note the rare, but proper, use of the final modifier. (There were rumors of a BooleanWrapper too!)

public class IntWrapper
{
  private final String value;

  public IntWrapper(int value)
  {
    this.value = String.valueOf(value);
  }

  public String getValue()
  {
    return value;
  }
}


Eastern Polish Christmas Tree Notation

Once my team was handed some code written by an outsourcing company. The code had been formatted into "Eastern Polish Christmas Tree Notation" (that's what they called it, anyway). The . was always aligned in the center of the page and everything else surrounded it. This formatting was enforced by the two Polish architects who would reprimand any deviations and were found late at night tabbing their way through normal developer's code to ensure it met their strict guidelines. Again, it's only funny in its idiocy. (This code is no longer in production, unfortunately)

public
DataPair[] getHotelInformation(String hotelId, String informationId)
                                      {
                                        return getHotelInfo("EN", hotelId, informationId);
                                      }

public
DataPair[] getHotelInformation(String lang, String hotelId, String informationId)
                                      {

                           String key = "_HOINF_"+lng+"_"+hotelId+"_"+informationId;
                       DataPair[] tbl = (DataPair[])csh.getObject(key);
                         if(tbl!=null)  return tbl;

                        Connection cn = null;
           OracleCallableStatement cs = null;
                                  try {
                           String qry = " begin HotelServices.getHotelInfo(?, ?, ?, ?, ?); end; ";
                               logger . debug("---"+qry+" "+hotelId+" "+informationId);
                                   cn = DriverManager.getConnection("jdbc:weblogic:pool:oraclePool",null);
                                   cs = (OracleCallableStatement)cn.prepareCall(qry);
                                   cs . registerOutParameter(1,java.sql.Types.INTEGER);
                                   cs . registerOutParameter(2,java.sql.Types.OTHER);
                                   cs . setString(3,hotelId);
                                   cs . setString(4,informationId);
                                   cs . setString(5,lang);
                                   cs . execute();
                              int sta = cs.getInt(1);
                            if(sta!=0)  throw new Exception("status not zero sta="+sta);
                         ResultSet rs = cs.getResultSet(2);
                                  tbl = getDataPairArray(rs);
                               logger . debug("sta="+sta+" key="+key+" cn="+cn);
                                  csh . put(key,tbl);
                                      }
                                 catch(Exception e)
                                      {
                               logger . debug("!!! "+e.toString()+" "+key);
                                      }
                               finally
                                      {
                                  try {
                      if(cs!=null) cs . close();
                      if(cn!=null) cn . close();
                                      }
                                 catch(Exception x)
                                      {
                               logger . debug("!!! "+x.toString()+" "+key);
                               logger . error("!!! "+x.toString());
                                      }
                                      }
                                return tbl;
                                      }


Submissions Welcome

Although my examples are in java (because that's what I do), the challenge applies well to all languages. I'm sure the K5 crowd with its wit and technical expertise can come up with some pretty good ones. Note to you perl people: "cryptic" != "funny".

Disclaimer

The point of this is entertainment only. Although it probably isn't strictly legal to post corporate source code, stupid little stuff like what I've posted isn't letting loose any industry secrets upon which my previous employers' success depends. The really important algorithms probably aren't very funny, anyway.

Sponsors

Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure

Login

Poll
Most entertaining of examples
o StaleBreadcrumbException 12%
o Royal Food Taster 2%
o McNugget 15%
o The Last Resort 2%
o Integer Wrapper 2%
o Eastern Polish Christmas Tree Notation 64%

Votes: 39
Results | Other Polls

Related Links
o Prevayler project
o RoyalFoodT aster
o Also by Milo Minderbender


Display: Sort:
Code Humor Challenge | 241 comments (223 topical, 18 editorial, 0 hidden)
Could you explain the Integer Wrapper joke (2.50 / 6) (#1)
by caek on Tue Jun 01, 2004 at 05:30:56 AM EST

I don't get it! If you want to avoid ruining it for people who are less dumb then perhaps in reply to this comment rather than in the article.

I guess this doesn't count, but... (2.58 / 17) (#4)
by spasticfraggle on Tue Jun 01, 2004 at 05:46:37 AM EST

The Power architecture assembly has an EIEIO instruction (Enforce In-Order Execution of IO).

--
I'm the straw that broke the camel's back!
merry xmas (2.80 / 5) (#11)
by Highlander on Tue Jun 01, 2004 at 07:16:02 AM EST

I kind of like the xmas tree notation, it looks like maybe an assembler programmer would like it. It would be ok to have an editor that does format code like this, but doing it by hand is a plain waste of time.

This needs a way to show the indentation level, aligning all "{" and "}" along the center is silly. Also, aligning all "." doesn't make sense anymore when you got objects nested deeper than 1 level("my.car.tire.pressure"). Of course you could forbid this and ask people to define a temporary "for readability" :-)

Moderation in moderation is a good thing.

whoohoo! (1.07 / 14) (#12)
by ljj on Tue Jun 01, 2004 at 07:17:08 AM EST

technology AND culture!

-1.

--
ljj

Can't beat the... (3.00 / 10) (#17)
by onealone on Tue Jun 01, 2004 at 08:01:14 AM EST

Guru.

Best I ever saw (3.00 / 10) (#23)
by Bjorniac on Tue Jun 01, 2004 at 09:00:33 AM EST

A basic program had the loop: REPEAT .... UNTIL THECOWSCOMEHOME
Freedom for RMG! Join the Jihad...
Hungarian notation (2.28 / 7) (#27)
by Ricochet Rita on Tue Jun 01, 2004 at 09:31:08 AM EST

seems to be ripe for this sort of thing.

For example, the instance boolean prefix, ib_ (pronounced "I be"), is highly abusable:

ib_functional
ib_dutyful
ib_leever
ib_indyErr

or Local Objects:

lo_fat
lo_nBrau
lo_self(eSteam)

Unfortunately, the code review staff here has no humor & removes the bulk our "creativity."
But it lives on in CVS!

Then at the other end of the spectrum, there's our "test user" database, with 100's of names like:

Ima Pseudonym
Juan Moore-Thyme
Harrison Fondel
Holly Peño
Mike O. Tocksen
Max Illias
Otto E. Rotik
Mona Knight-Rhayt
Auntie D'Loovian
Darron Dew
Ethyl Lynn Glycaul
Ester O'Jhen
Tess Tossterrone
P. Ann Issamo
Claude Balz
etc. etc. etc.

Since this part of the product doesn't ship out, it's largely beneath the reviewers' radar.

FABRICATUS DIEM, PVNC!

Stupid (2.42 / 7) (#30)
by guyjin on Tue Jun 01, 2004 at 09:48:02 AM EST

I once had to write an example program for a programming class that would take a few tests (I forget how many, it wasn't arbitrary) and average them for every student in a class. I assigned each student a 'STUdent Personal IDentification' number.

I'm sure someone else came up with the idea before me, though, and that it's floating around in some school grading system somewhere.
-- 散弾銃でおうがいして ください

Check your configurations (2.73 / 23) (#43)
by unixrat on Tue Jun 01, 2004 at 12:03:10 PM EST

While working for a small software company in Duluth, Minnesota, we maintained a small office in downtown, on Superior Street.  There was a small (<500 sq ft.) 'grocery' store near there that stocked various bits of dusty merch.  Every so often we would head down there for some coding fuel.  Between there and the office there was a Chinese restaurant - a rather terrible one IIRC.

While walking toward the Grocery store on a Monday afternoon, we observed two men get out of a pickup, walk up to the doors of the restaurant and try and open it.  It was locked.  They pulled and pulled, but it was obvious to everyone else that the placed was closed.  They started pounding on the doors and doing the cupped-hands-look-in.  They must have been damn hungry.  Anyways, after thirty seconds of futility, one of the kicks the door and yells "What is this, some sort of f*cking Chinese holiday?".  Then they leave.

Every program that we wrote after that had an "FCH" setting in the configuration file.  It was always set to 0 and there was no way to view/modify it through the prog.  If you looked at the config files by hand, it was there, uncommented, sitting all alone.  

If some poor fool would set it to '1', the program would silently quit during startup, never to run again until FCH was set back to '0'.  

User Unfriendly application (2.00 / 7) (#47)
by Orion Blastar on Tue Jun 01, 2004 at 01:34:25 PM EST

In High School I wrote a User Unfriendly program in Turbo Pascal.

The user was asked to enter a number, if it was not a valid number, the program added 1 to a counter and asked them to enter a number, no letters or symbols, just use the number characters. After 6 tries of this, it displays a message. "Don't you know the difference between a number and a letter? How did you survive in school this far?" and exits the program.

Of course I was forced to take that part out, but it was funny.

The counter was named notanumberentered.

I was told by my teacher that it would make people mad as it insulted them and they may try to break the computer as a result.

A friend of mine wrote a procedure called getthesh*t, which he later renamed to getthejunk. It gathered input from the user.

I did write a coporate ASP app using the variable twiddle in VBScript to keep track of how many times the user clicked on a line of the web page. If it went over 30, it changed the font size, color, and style, 30 more clicks and it went back to normal. Dynamic HTML, got to love it!

In MS-Access, because a certain database had nulls and zeros entered for data they were trying to divide on, I wrote a function named zerotone (zero to one) that if the value was zero or null it was replaced with a 1, otherwise it was the number. I was told for this database that there was no zero values, but the users entered them anyway. Everyone called it zerotone as in zero tone and not zero to one. Division by zero in a query blew the whole thing up, but using zerotone in the denominator prevented that. All zero and null values they wanted as one anyway.
*** Anonymized by intolerant editors at K5 and also IWETHEY who are biased against the mentally ill ***

"cryptic" != "funny" (2.91 / 23) (#48)
by coderlemming on Tue Jun 01, 2004 at 01:36:06 PM EST

Note to you perl people: "cryptic" != "funny".

Wait a minute...



#!/usr/bin/perl

if ("cryptic" != "funny") {
  print "Cryptic PERL programs are not funny.\n";
} else {
  print "Cryptic PERL programs are funny.\n";
}






$ perl ./cryptic.pl
Cryptic PERL programs are funny.




--
Go be impersonally used as an organic semen collector!  (porkchop_d_clown)
Fun. (2.88 / 9) (#50)
by BigZaphod on Tue Jun 01, 2004 at 01:56:38 PM EST

Sticking stuff like that in is what makes programming fun.  Basically, there's two kinds of programming:  1) Programming to solve a problem.  2) Programming to solve someone else's problem.

It is the second kind of programming that is often the least rewarding.  When you're sitting in a cube and adding feature XYZ because marketing thought the flashing bright colors would sell more units, you simply have to do something to break down that nagging sense of futility...

So anyway, where I used to work a friend and I kind of got good at influencing people to have some fun with the code.  It seemed like just about every project we were working on eventually got some code in there someplace that had silly names or comments.  Everyone seemed to enjoy it.  I figure we were doing a public service by bringing some fun to the daily grind.  :-)

There are two big ones that I remember.  I can't give actual code, of course, but I recall some of the specifics anyway.

One instance had us doing some code to clean up some temporaries used in the calculation of something or other.  The data that needed cleaning up was in a list container of some kind.  The list was renamed to death_row and function that cleaned it up and freed the memory was something like TheExecutioner().  (I wish I could remember exactly...)  There were also many fun comments surrounding this code.  I think there was even something about the governor calling during some of the stages of determining what needed to go on death_row vs. what didn't.

The other instance that sticks out was a time my friend and I were going through a bit of a Mr. T phase.  We had this whole class loaded down with methods like PityDaFool( int fool ) and other Mr. T-isims.  That was fun.  The comments were especially rich...

Of course eventually both my friend and I were let go (a few months apart) and they lost one of their most senior developers in that time, too.  Something strange was going on there.  I don't miss it.

"We're all patients, there are no doctors, our meds ran out a long time ago and nobody loves us." - skyknight

i was fired for this one... (2.76 / 13) (#56)
by the77x42 on Tue Jun 01, 2004 at 03:06:00 PM EST

Classname = FatAss

Public Event FoodInSight()

Public Sub Eat(varFood)
    var_Food = var_Food - 1
End Sub

-------------

Private WithEvents Ralph [my boss's name] As FatAss

Dim var_Food As Variant
Dim bol_FoodVisible As Boolean

var_Food = CONST_EVERYTHING

Private Sub Ralph_FoodInSight()
   While bol_FoodVisible  
      Call Ralph_Eat(var_Food)
      If var_Food = 0 Then bol_FoodVisible = False
   Wend
End Sub


"We're not here to educate. We're here to point and laugh." - creature
"You have some pretty stupid ideas." - indubitable ‮

Printer on Fire (2.86 / 15) (#58)
by arcade on Tue Jun 01, 2004 at 03:20:44 PM EST

I posted this as 'editorial' earlier by mistake, this time it should come out as topical, with a bunch of more info added.

In the nice little file

/usr/src/linux/drivers/char/lp.c:

in the linux kernel, you find the following gem of a code fragment:

 } else if (!(status & LP_PERRORP)) {
 if (last != LP_PERRORP) {
 last = LP_PERRORP;
 printk(KERN_INFO "lp%d on fire\n", minor);
 }

"Printer on fire" is one of the classical unix error messages - with a good history to add.

Jesse Pollard explained it on usenet once (I quote, in full):

"

As I understand it, this message is related to a parallel port (input only style) status code - ready, online, check.

The "check" signal might have had a slightly different name, but it was a "unknown error".

The fire message came from the old drum printers. These had the alphabet on a 3 inch diameter steel drum, one ring of the alphabet for each colum.

Over this would run a ribbon, about 24 inches in width, and 10 feet long. This assembly was all mounted on a door to give access to the paper, and
the print hammers.

The print hammers are all mounted on a fixed base of the printer body, with the fanfold paper running over it.

The drum rotated about 1200 to 2400 RPM. Faster for higher speed printers.

What happens is that the ribbon gets worn and tends to slide toward the side of the printer that is printed on the most (ribbon shrinks, and it
is the right side of the printer). When working normally, the ribbon moves at about 1/4 the speed of the drum. Whenever the ribbon reached the end,
it would hit a switch that would reverse the direction of the ribbon feed.

When the ribbon started shrinking on the right, the entire roll would start bunching up on the right, leaving the left side of the drum
rotating at high speed, directly against the paper.

This condition generates quite a bit of paper dust.

It also tends to cause the paper to jam. If the jam isn't detected soon enough, the accumulated paper dust, ink dust, real paper, AND the rapidly rotating drum would generate enough heat-by-friction contact to start a fire.

This condition is made worse by the printer cleaning solution, which was usually denatured alcohol, whose fumes tended to collect in the ribbon. (had that start a fire once - somebody turned the printer on before the drum had dried; something sparked and there was a brief flash of flame)

The paper jam usually set off the "check" signal and the host would stop sending data to the printer, and report some message to the operator. Sometimes, the offline switch would also be triggered, which (at least in the printer) would stop the drum from spinning. The offline switch was actually triggered by a different condition. I think it was when the paper was no longer in contact with an "out of paper" sensor. If the offline switch wasn't triggered, the drum would continue spinning, and continue adding more heat.

The old lpd on UNIX v 6/7 used the check signal to report a "printer on fire" if the offline signal was NOT present. I believe it was the combination of offline and check signal that was used to generate the "out of paper" message.

"

His original message can be found with the message ID: "<linux.kernel.200208092200.RAA34736@tomcat.admin.navo.hpc.mil>" via groups.google.com

--
arcade

Not in the code but in the project name (2.80 / 5) (#65)
by trollbuster on Tue Jun 01, 2004 at 04:00:09 PM EST

For our final project in college our group decided to to a home security system complete with sensors and a keypad control panel that reported intrusions to a central computer. Because this particular school has a good reputation in the business community of the city our group had to set up an "official" company name for the project as recruiters would usually look at projects at the end of the year. We decided on Secure Homes Integrated Technology. I don't see what the problem was as we always typed out the name in full in all documentation and never used an acronym. After using the name for two months our instructor finally noticed and we got a note from him to change it because it "wasn't very professional" with no reason given. Had a hell of a time trying to come up with another good name and I think we finally just rearranged the words somehow.

"I am Joe's Pancreas" (none / 2) (#72)
by claes on Tue Jun 01, 2004 at 05:05:32 PM EST

Was, I'm pretty sure, displayed once in a while on the control panel for a multi-million dollar Ion Implanter.

Any other Eaton ex-employes remember that one?

-- claes

Oooh I've got one (2.50 / 4) (#73)
by ksandstr on Tue Jun 01, 2004 at 05:15:33 PM EST

Though this is really an oo reference more than humorous by itself, in cases where a separate datatype wasn't warranted but you still needed to pass several things through an interface where only one would fit, I've been known to pass around void *foo[2] arrays (or, in evul evul javur, Object arrays) that are initialized somewhat like this:

void **params = g_new(void *, 2);
params[0] = first_parameter; /* ONE IS THE JEWEL OF THE NILE */
params[1] = second_thingy; /* THE OTHER IS THE MOON AND STARS */

Cute, and particularly effective if you're passing something small but important as the first parameter and a pointer to a larger context type thing as the second. Seeing as there isn't much point in trying to make C (or Javur, for that matter) look pretty, most people in our team just make do with snide block comments. Of course there are things like the nearly infamous ERR_SHRUBBERY #define that couldn't be removed for historical reasons, but being accidental it shouldn't count.

Funniest example I've seen so far is in the Haskell HaXml library's Combinators module, where "left of right" type combinations are achieved with the `o` form, informally known as Irish composition. The fun really carries over into ordinary code, so you'll end up with things like children `o` deep (tag "cthulhu").

Fin.

for class, but... (2.78 / 14) (#75)
by pb on Tue Jun 01, 2004 at 05:28:55 PM EST

From a threaded tftp server written for class, I created a 'pocket' datatype that consisted of a tftp packet and a socket:

struct pocket {
        struct packet * p;
        struct sockaddr * s;
};

(note: this was so I could pass it as one argument on the stack, using thr_create)

Hence, this comment (shamelessly stolen, apologies to Dr. Seuss and the original author(s)):

/*********************************************************
If a packet hits a pocket on a socket on a port,
And the bus is interrupted as a very last resort,
And the address of the memory makes your floppy disk abort,
Then the socket packet pocket has an error to report!
*********************************************************/

---
"See what the drooling, ravening, flesh-eating hordes^W^W^W^WKuro5hin.org readers have to say."
-- pwhysall

long time(); /* know C */ (2.88 / 17) (#77)
by gidds on Tue Jun 01, 2004 at 05:49:03 PM EST

I'm surprised no-one's mentioned this yet. Back in 1988, Mike Shon wrote a whole C program based on puns -- it's here.

Andy/
This isn't mine, but... (2.86 / 15) (#84)
by vadim on Tue Jun 01, 2004 at 07:37:12 PM EST

Put this in a header:

#define struct union /* Saves memory */
#define while if /* Saves CPU time */

--
<@chani> I *cannot* remember names. but I did memorize 214 digits of pi once.
hmmmm... (2.81 / 11) (#86)
by xcham on Tue Jun 01, 2004 at 08:04:59 PM EST

I can't take credit for this, this was my friend Andrey's humourous addendum to his first year Comp Sci final project: class Feces extends Exception { // etc.. } somewhere else.. public void Monkey(boolean bowelMovement) throws Feces { if (bowelMovement == true) { throw new Feces(); } }

odd error messages (none / 3) (#87)
by ajaxx on Tue Jun 01, 2004 at 08:09:51 PM EST

i can't claim credit for this one.  i've got a wireless bridge with flashable firmware.  the firmware ships as ARJ archives (why god why).  running strings(1) on the decompressed firmware yields this little beauty:

Hey Moe, it dont woik. NYUK NYUK NYUK NYUK bop Owww!

no idea how one would trigger that, particularly on a device with only web and tftp interfaces.

apple's C compiler (pre-OSX) had several humorous error messages which weren't too tough to trigger.

Great example in classic BSD code (3.00 / 8) (#88)
by ataraxia on Tue Jun 01, 2004 at 10:32:48 PM EST

Can't belive nobody has posted this one yet... This code has been around since the Berkeley days, I think. FreeBSD, /src/sbin/shutdown/shutdown.c has this set of prototypes:

void badtime(void);
void die_you_gravy_sucking_pig_dog(void);
void finish(int);
void getoffset(char *);
void loop(void);
void nolog(void);
void timeout(int);
void timewarn(int);
void usage(const char *);

Spot the joke. It's a real function, too!

--
Don't do something if it's stupid.
DEC VMS (3.00 / 8) (#91)
by krait on Tue Jun 01, 2004 at 10:38:32 PM EST

The VMS operating system, originally developed by Digital Equipment Corporation to run on VAX computers, and since ported to Alpha and IPF based systems, has some of the best acronyms embedded in it. Some classics like ICBM (IOGEN Configuration Building Module), and NSA (Non-discretionary Security Auditing), CIA (Compound Intrusion Audit), and KGB (Key Grant Block), all associated with the security subsystem spring to mind.

However, the absolute best was working FUBAR into hardware. The acronym stood for "Failed UniBus Address Register"

Quoting from the original "VAX Technical Handbook":

The VAX- 11/780 UNIBUS Subsystem

Failed UniBus Address Register (FUBAR)

The FUBAR contains the upper 16 bits of the UNIBUS address translated from an SBI address during a previous software-initiated data transfer. The occurance of either of two errors indicated in the status register will lock the FUBAR: UNIBUS Select Time Out (UBSTO), and UNIBUS Slave Sync Time Out(UBSSYNTO). When the error bit is cleared, the register will be unlocked.

The FUBAR is a read-only register. Attempting to write to the register will result in an error confirmation. No signals or conditions will clear the register.

If your VAX was FUBARed, it was truly FUBARed in the classic sense of the word.



Fun with Dates (2.92 / 13) (#92)
by Shibboleth on Tue Jun 01, 2004 at 11:25:30 PM EST

I once had to write a program which performed certain operations on data arrays that had a year value between 1970 and 1978. Therefore:

Cool = True
Uncool = False

Disco = Uncool


Do Until Disco = Cool

if Year gt 1970 And Year lt 1978 then

GetDownAndDance
Disco = Cool

Else

MockDiscoDancers

End if

Loop


I've got one (3.00 / 9) (#93)
by Tatarigami on Tue Jun 01, 2004 at 11:49:52 PM EST

Back in my previous job, if you tapped CTRL + more than one key, the customer database would throw up a 'cat on keyboard' error.

Stoopid (2.66 / 6) (#96)
by Brandybuck on Wed Jun 02, 2004 at 12:38:38 AM EST

An authentication function I wrote last year for an embedded system:

void stupidBackdoorThatMarketingWants()

Got plenty (3.00 / 6) (#97)
by OzJuggler on Wed Jun 02, 2004 at 01:30:02 AM EST

Gosh, where to start? :-)

This was in a VB app of ours which the user is not supposed to be able to exit from, but that's a real pain when you're debugging, hence...

Sub GetTheHellOutOfHere()
    ttermModel.Destroy
    Unload fMainForm
    End
End Sub

...later...

    'SUPER SECRET back door! Ctrl+Alt+F12
    If (KeyCode = vbKeyF12) And sCtrl And sAlt Then
        GetTheHellOutOfHere
    End If

And elsewhere a humorous default error message if none of the other cases are handled...

Sub TranslateErrors()
    If ttermModel.LastError = ttermModel.teOK Then
        LastErrorStr = ""
    Else
        '!! This was added 21/5/2001 in compliance with
[department manager]'s directive for
        '   the adoption of Haiku error messages.
        LastErrorStr = "Chaos reigns within." & Chr(10) _
                     & "Reflect, repent, and reboot." & Chr(10) _
                     & "Order shall return."
        Select Case AppState
            Case tsEmpNum
                Select Case ttermModel.LastError
                    Case teUnableToValidate
                        LastErrorStr = "Unable to validate employee number."
                    Case teInvalidParameters
                        LastErrorStr = "Invalid employee number entered."
                    Case teAlreadyThere
                        LastErrorStr = "You have sessions open on other terminals.  " _
                        & "Close the other sessions or wait for them to time out."
                End Select
    [..and so forth....]

The menu screen structure was modelled as a FSM, but since pressing Escape never needs to go to any state other than the previous state,
why waste space and time maintaining a whole history of screen navigations when you only need one variable to store the previous one?
So in the code for handling state transitions...

        If Not cancelled Then
            ShortAttentionSpan = AppState
            AppState = ns
        End If

Our app even had context-sensitive help!

Private Sub ShowHelpFor(helpContext As String)
    frmHelp.GetTherapy helpContext
End Sub

Of course a favourite target of code humour is creating and killing processes... or threads in this Java example...

            Timer asassination = null;
            if (spec.maxSeconds>0) {
              //Enforce maximum allowable execution time.
              asassination = new Timer(true);
              TimerTask sniper = new TimerTask(){
                public void run(){
                  proc.destroy();
                  this.cancel();
                  //!! generate an event and send to scribe.
                  PamEvent pe = new PamEvent();
                  pe.eventType = PamEvent.ET_NATIVE_EXCEEDED_TIMELIMIT;
                  pe.sourceTest = spec.testIDNum;
                  recorder.recordEvent(pe);
                }
              };
              asassination.schedule(sniper, spec.maxSeconds*1000); //One shot. One kill.
            }

And I can guarantee that all of these examples are in production right now.
Ah the luxury of being the sole analyst/programmer.

"And I will not rest until every year families gather to spend December 25th together
at Osama's homo abortion pot and commie jizzporium." - Jon Stewart's gift to Bill O'Reilly, 7 Dec 2005.

This is a funny ancedote (2.70 / 10) (#98)
by Resonant on Wed Jun 02, 2004 at 02:15:03 AM EST

...or at least I think it is. My friend is sitting coding one day, and I am watching him (I forget what we were working on). All of the sudden he opens up a new file, and writes this (C++): int main() { while(1) { do(yourmom); } } and I responded "Dude, your going to be really tired". So without missing a beat, he goes back and puts this: int main() { while(1) { do(yourmom); sleep(100); } } The hard thing to convey with that story is the speed at which it happened. The whole event lasted probably 20 seconds. Ironic, is it not?

"I answer, 'This is _quantitative_ religious studies.'" - glor
A friend sent me this (none / 3) (#100)
by Wildgoose on Wed Jun 02, 2004 at 02:56:01 AM EST

He was working as a COBOL programmer at Royal & Sun Alliance, a large British Insurance company. He came across a list of variables all beginning "CAMP", in the middle of which was one named "CAMP-OOH-DUCKIE".

I thought of another one (2.50 / 4) (#101)
by Milo Minderbender on Wed Jun 02, 2004 at 03:22:14 AM EST

The teenage sense of humor that still resides within me likes this one... I wrote an e-commerce system once that generated "e-coupons" and sent you a code via email that you could type in to the site and get a discount if it applied to an item in your shopping cart. One of the subsequent requirements was to make a type of e-coupon that could be mass-mailed to all the people subscribed to receive e-coupons. I resented this requirement at little bit because it sounded a little like unwanted email (even though the unsubscribing really did work). I almost named them:
spampons


--------------------
This comment is for the good of the syndicate.
One of my inept favourites. (3.00 / 8) (#113)
by scross on Wed Jun 02, 2004 at 08:40:57 AM EST

One of my all time favourites. The programmer appears to want to ensure that his string was zero terminated.
strcat(buffer, "\0");

Cheers, Sarah
Making a daemon... (2.50 / 4) (#114)
by beggs on Wed Jun 02, 2004 at 09:24:59 AM EST

This is from one of my first projects but I believe it is still out there:

void blasphemy(bool daemon){
    int pid = fork();

    // start child process
    switch(pid){
      case -1:
        fprintf(stderr, "COULD  ;NOT FORK -- EXITING!\n");
        exit(-1);
        break;
      case 0:
        // child -- all&n bsp;is good.
        break;
      case 1:
        // parent -- kill .
        exit(0);
        break;
      default:
        // fork() on sola ris returns the child pid to the parrent  ;on success so any positive 
        // return value i nicated that we are the parrent. 
        exit(0);
        }
    if(daemon){
        // only the daemo n process should ever get here...
        fprintf(stderr, "daemon&nbs p;process id: %i\n", (int)getpid());
        }
}

bool curse(){
    // blasphem once and you can&nb sp;be saved
    blasphemy(FALSE);
    // set group to null;
    setpgrp();
    // blasphem twice and you are&n bsp;cursed
    blasphemy(TRUE);

    // no one hears the cursed  ;screem
    fclose(stdout);
    fclose(stdin);
    fclose(stderr);

    return(TRUE);
}

--- -- ---- - ----- --------- :: brian jeffery beggerly :: :: beggs@SPAM.confusion.cc :: :: http://confusion.cc :: - -- ------- -------- -------
How about GNU libc... (3.00 / 7) (#116)
by jreilly on Wed Jun 02, 2004 at 11:36:37 AM EST

All C programmers know about strstr, strcpy, etc, right? Well, the gnu coders clearly got bored one day and threw in:
char* strfry(char*)
which obviously randomly swaps around characters in a string =)

Oooh, shiny...
Old time COBOL (2.80 / 5) (#117)
by xptm on Wed Jun 02, 2004 at 11:42:10 AM EST

Back in my early years i was doing some COBOL, and used var names like 'wine', 'barrel', 'bottle', so i can write move wine from barrel to bottle. perform DrinkWine until BottleIsEmpty. and things like that.

hm (none / 3) (#119)
by EMHMark3 on Wed Jun 02, 2004 at 12:43:32 PM EST

Had this for a sig a while back, can't remember where I got it from though:

if (false)
    panic();

T H E   M A C H I N E   S T O P S

Sun HME Linux Driver (2.80 / 10) (#122)
by rohrbach on Wed Jun 02, 2004 at 01:24:10 PM EST

The Sun Happymeal driver for Linux comments are quite nice ;-)

525         /* Welcome to Sun Microsystems, can I take your order please? */
526         if (!hp->happy_flags & HFLAG_FENABLE)
527                 return happy_meal_bb_write(hp, tregs, reg, value);
528
529         /* Would you like fries with that? */
530         hme_write32(hp, tregs + TCVR_FRAME,
531                     (FRAME_WRITE | (hp->paddr << 23) |
532                      ((reg & 0xff) << 18) | (value & 0xffff)));
533         while (!(hme_read32(hp, tregs + TCVR_FRAME) & 0x10000) && --tries)
534                 udelay(20);
535
536         /* Anything else? */
537         if (!tries)
538                 printk(KERN_ERR "happy meal: Aieee, transceiver MIF write bolixed\n");
539
540         /* Fifty-two cents is your change, have a nice day. */
541 }

A complete and online version can be found there:
http://lxr.linux.no/source/drivers/net/sunhme.c

Regards,
/k

--
Give a tool to a fool, and it might become a weapon.

GPL == Amateur (1.06 / 15) (#124)
by FeersumAsura on Wed Jun 02, 2004 at 04:34:00 PM EST

The majority of examples that have been given by people are quite interesting, what is disturbing is those that are grossly unprofessional and show a level of humour that a five year old would be ashamed of. It was clear that the VB programmers had a much lower standard of code and humour, but the C users didn't fare too well either.

What was most interesting was that it highlighted how unprofessional some programmers are and that the "coders are god" ethos still pervades. This is the reason you're all unemployed, you can't act professionally in a professional environment. Just do what you're asked to do, take the money and run. If you want to make lame jokes, or bad puns work on a joke project and GPL it. No one will notice it as it becomes lost in the plethora of crap on sourceforge and there's no danger of being fired. If this business continues then the notion of GPL == amateur will become truer than it already is.

I'm so pre-emptive I'd nuke America to save time.

Perl code of biblical proportions (2.75 / 4) (#126)
by LrdChaos on Wed Jun 02, 2004 at 05:12:43 PM EST

This one's in Perl, but it's not being cryptic that makes it funny. The code isn't mine, it's from the source code to a web messageboard that I helped out on for a brief period:

sub chomp_url ($$) {
 my $the_red_sea = shift;
 return $the_red_sea if $the_red_sea =~ /^<img src=/;
 return $the_red_sea unless length($the_red_sea) > 70;
 return $the_red_sea unless $the_red_sea =~ m!://!;
 # Fix up 'dem pesky ampersands
 $the_red_sea =~ s!&!&!g;
 $the_red_sea =~ s!(?:(\?)|[&;])s=[\w\d]{16,32}(?:&|;|$)!$1!g;
 my ($moses, $did_indeed) = split /\:\/\//, $the_red_sea;
 my @miracle = split "/",$did_indeed;
 my $worker = substr($miracle[1], 0, 7,);
 my $maybe = substr($miracle[$#miracle],length($miracle[$#miracle])-7);
 return $moses.'://'.$miracle[0].'/'.$worker.'....'.$maybe;
}


man 3perl errno (on debian) (none / 1) (#128)
by vadim on Wed Jun 02, 2004 at 05:17:25 PM EST

use Errno;

unless (open(FH, "/fangorn/spouse")) {
if ($!{ENOENT}) {
warn "Get a wife!\n";
} else {
warn "This path is barred: $!";
}
}

--
<@chani> I *cannot* remember names. but I did memorize 214 digits of pi once.
Author unknown (3.00 / 7) (#129)
by walwyn on Wed Jun 02, 2004 at 05:24:18 PM EST

Declaration of a Software Professional

class SoftwareProfessional
{
private:
   double  salary;
   long    lunches;
   float   jobs;
   char    unstable;
   void *  work;

private:
   complex UpdateSkills();
   long    DownloadPictures();
   long    PlayNetworkGames(SoftwareProfessional& OtherProfessional);

public:
   short         PaintTheManagers();
   virtual void  WorkDuringDay() = 0;
   long          SendMails();
   long          ReceiveMails();
   long          Send(Pictures& pictures);
   long          Send(Jokes& jokes);
};


----
Professor Moriarty - Bugs, Sculpture, Tombs, and Stained Glass

Users (none / 2) (#138)
by sethadam1 on Wed Jun 02, 2004 at 08:54:11 PM EST

I have written every character of my company's intranet, and the server side code is FILLED with sarcastic quips, funny functions names, and stupid comments, but by far, my favorite is this:

Anytime a new form/application on the intranet needs to maintain it's own user source, I aalways populate the db with my test users: Agustus Gloop, Veruca Salt, Mike TeeVee, Violet Beauregard, and Charlie Bucket.  

Profanity filter (2.85 / 7) (#141)
by motty on Wed Jun 02, 2004 at 10:50:31 PM EST

I was once asked to write a profanity filtering module in Perl for a certain well-known UK-based website, and managed to get away with calling it the 'Multiply Extensible Rude Description Eliminator', or 'Merde' for short.

I was not a happy bunny at the time; somewhere in cvs is a commit commented something like 'Removed profanities from comments', and another, commented 'Removed profanities from error messages'.

It's still in use.
s/^.*$//sig;#)

USS Unifarce (none / 2) (#142)
by davros4269 on Thu Jun 03, 2004 at 12:13:33 AM EST

My boss was actually a programmer who looked at our code, I never got to do anything funny...

I did manage to put in some funny comments and even some stupid ASCII pictures, like a picture of a fly with the comment something like, "I feel sorry for the next person that has to work on this pile of shit" - this was a few days before I quit...

I was working in Uniface at the time - really ridiculous environment, anyway, it was a mostly worthless GUI wrapped around a generic database engine - in order to access a table in the code, that table had to be "drawn" on the GUI - so amongst the visible fields and such we had to draw tables and hide them - that is, draw an element which represented a certain table, usually as small as the GUI editor would allow and then set it invisible...

I did this once and it sorta looked like a Star Trek ship, so I arranged the inviable tables more into the shape of a ship and added the invisible label, "USS Uni-farce" over it...

We had a multi-player tic-tac-toe game written - I was just making an AI when the boss axed the "project"...:(


Will you squirm when you are pecked? Quack.

Ha! (2.50 / 6) (#146)
by Milo Minderbender on Thu Jun 03, 2004 at 03:58:39 AM EST

This page is the top google hit for "Polish McNugget". :-)

--------------------
This comment is for the good of the syndicate.
No point in assigning zero when it already is (none / 2) (#147)
by lookout on Thu Jun 03, 2004 at 04:44:16 AM EST

if x <> 0 then x = 0

(from a Basic program anno 1980)


not source code but manpage humour (2.75 / 4) (#150)
by kingcnut on Thu Jun 03, 2004 at 06:15:06 AM EST

Irix 6.5 dmedia.eoe Release Notes

fightclub in code... (none / 3) (#162)
by Ashalind on Thu Jun 03, 2004 at 09:58:51 AM EST

I've seen things like:

#if defined (BOSS_A_WANTS_SOMETHING) && !defined (BOSS_B_WANTS_SOMETHING)
<piece of code>
#if !defined (BOSS_A_WANTS_SOMETHING) && defined (BOSS_B_WANTS_SOMETHING)
<another piece of code>
#else
#error FIGHTCLUB
#endif

somewhere in sources of a big and complicated piece of software, that was still in development and subject to change almost every day, depending on what the Important People deemed to be preferred that morning... :)

char Broiled (none / 2) (#170)
by craigd on Thu Jun 03, 2004 at 12:55:27 PM EST

an old classic, allegedly snuck into multiple programs. May be a myth.


A man who says little is a man who speaks two syllables.
a_variable_name (none / 1) (#179)
by static on Thu Jun 03, 2004 at 10:32:14 PM EST

I've been known to use $xyz in PHP because I couldn't be bothered thinking up yet another variable name.

But in the unit tests, we could go to town. :-) I did up some code to test a number of time-matching and checking functions. So there as $a_time, $a_nother_time, $an_earlier_time, $a_nother_earlier_time, $a_later_time,... and so on and so forth.

Wade.


The funny thing is... (none / 2) (#180)
by readams on Fri Jun 04, 2004 at 01:01:12 AM EST

That supposedly "inept" int wrapper has genuine uses in Java. It's called a boxed representation of the integer, and allows you to do things like have an integer that can be null, or store the integer in a list or use it as a hash key. It happens to duplicate a class that's already available in the Java API, but failing to discover a class in the Java API is hardly total ineptitude.

Database instance names (3.00 / 4) (#190)
by Ricochet Rita on Fri Jun 04, 2004 at 10:49:04 AM EST

::Slaps forehead:: I completely forgot about these...

The Oracle database historically uses 4-letter System ID names (SID's), with "orcl" being the default. Here are some of the ones we've used over the years, for various development & production instances (keep in mind that these are internal to the DB & *none* of the users have access to them, let alone the acronym key...):

ACID -- Aegis ComSys Integrated Database
AHOI -- Another Heinious Oracle Instance (production box for a Dept of Navy application)
ACME -- Acronyms for ComSys Made Easily
BABY -- Bring Another Beer, Yohimbe
DADA -- D. Asks, Development Answers (D. being the proj manager's name)
DUDS -- Development Understands, D. Shrugs
DODO -- Developmental Obfuscation Done Obsequiously
CRUD -- ComSys Remains Under Development (it was a looong project...)
CULT -- ComSys Used for Limited Time (years later, still in use!)
CONS -- ComSys On New Server
C*NT -- ComSys Under NT (a short-lived dev instance on WinNT)
DONT -- Development On NT (D's responce to the previous SID!)
DEFY -- Database(Doubtfully) Existing For Years (our meta-responce to the above)

A number of these are still in use today!

FABRICATUS DIEM, PVNC!

"true" (none / 1) (#201)
by WWWWolf on Sat Jun 05, 2004 at 09:10:09 AM EST

In PHP, like in Perl, all strings not equal to "0" are true in boolean context.

So, in one particular case, I used this string as a "true" value. Can't remember how it went, copied and pasted it from the web, but the end was the most famous part of it: "...for I am become Death, the shatterer of worlds."

The code was for getting the user confirmation for nuking something from the database. That kind of situations probably require some drama.


-- Weyfour WWWWolf, a lupine technomancer from the cold north...


chop $uey; (2.80 / 5) (#202)
by NoseyNick on Sat Jun 05, 2004 at 12:09:15 PM EST

naming your temporary variables "uey" in perl, purely so you can chop $uey; :-)

I don't think we're in Kansas anymore Toto (2.75 / 4) (#203)
by sheepy on Sat Jun 05, 2004 at 12:42:43 PM EST

As a electronics technician some years ago I dropped a screwdriver into an emulator, after the smoke cleared I saw this on the terminal:

System Error:I don't think we're in Kansas anymore Toto

"Freedom is the right to be wrong, not the right to do wrong." John G. Riefenbaker

The best I've seen is an Opcode name (none / 1) (#211)
by dukerobillard on Sun Jun 06, 2004 at 11:03:42 AM EST

In the IBM PowerPC instruction set, there's actually an opcode called "Enforce In-Order Execution of I/O". In "Old MacDonald" fashion, the abbreviation is EIEIO.

http://hpcf.nersc.gov/vendor_docs/ibm/asm/eieio.htm

Hey, yeah I do that sort of stuff! (none / 0) (#213)
by A synx on Mon Jun 07, 2004 at 04:07:19 AM EST

Nothing wrong with slipping a little humor in code after all, we remember things we laugh at!


I often in threaded programming have the use for only one lock for the entire program.  Pretty much just a cheap way to share variables: lock the big mutex and then check/change all your shared variables, then unlock it for everything else.  For this mutex lock I was at a loss as to what to name it, when I suddenly recalled the game "popcorn" where people read out loud in a classroom and when they're done they toss the popcorn to the next reader.  Thus...

pthread_mutex_t popcorn = PTHREAD_MUTEX_INITIALIZER;

Hm... what's some other things I do... :)


sub Plumber {
        #SIGPIPE detected, but it'sa alright.
        print "Your princess is in another castle.n";
        exit(0);
}
$SIG{'PIPE'} = &Plumber;

Here's one I put to filter naughty subject lines in spam:


sub soap {
        # Wash yo' mouth out wif soap!
        $_ = shift;
[ lots of substitutions here ]
        return $_;
}

I'd find some more, but I got another thing to work on.  Now I know to combine code and puns intentionally.  I will do so subtly from now on!  Thanks muchly.



I actually thought of one (none / 1) (#223)
by epepke on Tue Jun 08, 2004 at 06:14:18 AM EST

One of my first commercial programming assignments, way back when giant lizards roamed the Earth, was to disassemble the Xerox 820-II Bios and modify it so that it could do synchronous as well as asynchronous communications. Getting this done would be a story in and of itself.

Anyway, I couldn't exactly understand one of the routines. So I named it McGuffin. It's from a not-particularly-funny joke that's probably 70 years old by now. A guy goes into a train compartment and puts something mysterious in the luggage rack above. Someone asks him what it is. The following dialogue ensues:

Q: What's that?
A: It's a McGuffin.
Q: What's a McGuffin?
A: It's a device for detecting lions on the Scottish highlands.
Q: But there are no lions on the Scottish highlands.
A: Well, then that's no McGuffin.

Alfred Hitchcock made his movies around McGuffins (the secret letter, the hidden plot) that were focal points of the plot but ultimately were meaningless.

My colleagues thought it was Egg McMuffin.


The truth may be out there, but lies are inside your head.--Terry Pratchett


I salute you (none / 1) (#233)
by ShiftyStoner on Mon Jun 14, 2004 at 04:06:10 PM EST

 for taking perhaps the most boring thing on the planet and trying to make it fun. It's still boring it's not gana make anyone laf. Unless theyd laf at a stick.

 Hey, now try making defraging fun.
( @ )'( @ ) The broad masses of a population are more amenable to the appeal of rhetoric than to any other force. - Adolf Hitler

I've never put funny code in... (none / 1) (#237)
by tonyenkiducx on Fri Jun 25, 2004 at 11:47:56 AM EST

..but I once slipped a copy of an old Atari game called CrossFire into the billing system of, what used to be called, Cable & Wireless. It was linked with a 1 pixel spacer gif from the main billing page, and even saved your score under your user acc! It dissapeared when they changed there name in the UK though :(

Tony.
I see a planet where love is foremost, where war is none existant. A planet of peace, and a planet of understanding. I see a planet called
You'll possibly only get this if your from the UK. (none / 2) (#238)
by u02sgb on Thu Jul 08, 2004 at 08:29:18 AM EST

We use Hewlett Packard Unix boxes for prototypes and to demo our systems for sales.

Our sysadmin named our new box "Sauce".

HP Sauce.. geddit :).

found in a header (none / 0) (#239)
by ericl on Tue Jul 13, 2004 at 08:02:31 PM EST

a header comment in some code at a big internet auction company (that you all probably know) has this in it -

@author a rank amature called edited who has never written a line of code before, needs to be treated like a 5 year old child, and is managed by people that should be managing a sweat shop that are even less competent than him.

Prolog (none / 0) (#240)
by robinmacharg on Fri Jul 23, 2004 at 11:52:01 AM EST

I could never really get my head round Prolog, but I did manage to express a degree of self depricating irony in it. The program:

funny(robin):- false.
funny(_):- true.

Generates output such as:

> funny('a horse walks into a bar...').

Yes.

> funny(robin).

No.


alt.language.bad (none / 0) (#241)
by wraith0x29a on Wed Jul 28, 2004 at 09:49:09 AM EST

Eventually some bright spark on our support team is going to notice that the two language options currently available for the PHP front-end on our SME business servers are 'UK-English' and 'BOFH-English'.

A (mildly censored) comparison..

lang/en-uk.php :

$lang['network_settings']['warn'] = "Caution: Entering incorrect information may cause your system to stop responding!" ;
$lang['network_settings']['good'] = "Network settings updated." ;
$lang['network_settings']['bad'] = "There was a problem with the network details you provided. Please try again." ;

lang/en-bofh.php :

$lang['network_settings']['warn'] = "For f*&^ sake don't f*&^ this up or you're really f*&^*d!" ;
$lang['network_settings']['good'] = "If you can see this then you are probably not too f*&^*d." ;
$lang['network_settings']['bad'] = "Uh-oh, you're f*&^*d." ;

..and some 300+ others.

So far only one system has been shipped with en-bofh still set as the default language.
It has been left that way at the customer's request.
"There are actually 11 kinds of people in the world: Those who don't understand binary, those who think they understand binary and those who know what little-endian means."

Code Humor Challenge | 241 comments (223 topical, 18 editorial, 0 hidden)
Display: Sort:

kuro5hin.org

[XML]
All trademarks and copyrights on this page are owned by their respective companies. The Rest © 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!