Humourous Programming

Associate
Joined
2 Nov 2005
Posts
931
Location
Leicester
Been teaching code (see other thread) and came up with an idea. If I make the code rather silly, they might learn better. First stab at "Humorous Programming":

Example of class "Aggregation" in Python:
Code:
class Bang:
    def __init__(self):
        print "Boom!"

class Wheel:
    fell_off = True

class Car:
    wheels = [Wheel(), Wheel(), Wheel(), Wheel()]
    rusty = True
    chitty_chitty = [Bang(), Bang()]

Contributions in other languages welcome :)
 
Previous programmer left me this humourous (for the wrong reasons) code

Code:
  if(firstName == firstName && firstName == firstName) {
     // do something
  } else if(firstName != firstName) {
     // do something
  } else if(firstName) {
     // handle error
  }
 
I've seen a list of humorous programming years ago. The one that sticks out in memory is this:

Code:
Exception up = new Exception();
throw up; // haha
 
Back
Top Bottom