We've all had some instances in our lives where we have either written or seen humorous code. Take this chance to talk about some instances (and even post code examples) of when you have written some real humorous code.
Some humorous code is obviously fake and contrived, such as the the many examples of the Windows source code we see around the internet. Don't post stuff like that.
My Example
Today I was writing some code to work with the ScrollViewer control in WPF and C#. I've subscribed to an event, so that every time the event fires some code should be executed, but I only want the code to be executed when the "ExtentWidthChange" variable is non-zero.
Since I don't trust comparing double values to 0.0 directly (I won't get into why), I convert it to an int to get a solid 0 value. Here's the code:
(If you don't see the humor in that code, shame on you)Code:void MyScrollViewer_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
int changeWeCanBelieveIn = Convert.ToInt32(e.ExtentWidthChange);
if (changeWeCanBelieveIn != 0)
{
MyScrollViewer.ScrollToHorizontalOffset(_percentScrollHorizontal * MyScrollViewer.ScrollableWidth);
MyScrollViewer.ScrollToVerticalOffset(_percentScrollVertical * MyScrollViewer.ScrollableHeight);
}
}
Post your own examples of humorous code...