CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Darrell Norton's Blog [MVP]

Fill in description here...

What's the best drunk code you've ever written?

Steve Hebert and I came up with this “Friday question”:

What's the best piece of code you've written drunk, on medication, etc.?

Best here can be loosely defined as good, humorous, obfuscated, commented, etc.

Mine was written under a Sudafed-induced state. Sometimes my allergies bother me so much I can’t stop sneezing until I’ve taken half-a-dozen of those little red pills. It keeps me up all night too. (My best friend’s wife is a pharmacist, so I know what I’m doing. Don’t try this at home. Side effects include drowsiness, inability to sleep, and intermittent narcolepsy. Keep your hands and legs inside the blog post at all times.) But I digress.

I was in the zone, cranking out the code. I thought I was making all sorts of great progress. Then I went to bed. The next day I woke up and encountered things similar to what these people found. I had to rewrite most of it, but it was an illuminating experience. Now when my allergies act up and the recommended dosage of Sudafed doesn’t work, it’s time to go home.



Comments

Darrell said:

That's awesome! Lightweights always make for great entertainment. :)
# July 16, 2004 3:54 AM

David Hayden said:

// TODO: write something here as soon as I finish my beer. ;)
# July 16, 2004 4:03 AM

Mike Carter said:

I wish I had a drunk coding story, but the truth is that once i geta buzz going, I lose all motivation to do anything productive.
# July 16, 2004 4:03 AM

Darrell said:

David - that's TODO-Driven Development! Find out more here: http://secretgeek.net/TODO_driv_dev.asp
# July 16, 2004 4:21 AM

Darrell said:

Mike - that's why Sudafed is great... no motivation lost yet coding ability is just as impaired!
# July 16, 2004 4:23 AM

Jason Row said:

I'm in the same boat as Mike. I don't do much drinking and coding so I have no stories to tell.

Question for next week, what music do you listen to when you code? Seems like Darrell likes Britney's In the Zone CD. <grin>
# July 16, 2004 4:52 AM

Jason Row said:

Maybe I'd drink more if I had access to one of these.

SkyBox Personal Beverage Vendor by Maytag
http://208.29.6.159/MainPage.aspx
# July 16, 2004 5:04 AM

Jason Row said:

Whoops ... try this URL instead.
http://www.skyboxbymaytag.com/
# July 16, 2004 5:07 AM

David Hayden said:

That TODO-Driven Development is hilarious and hits a little too close to home :)

Speaking of Test-Driven Development :)

I remember watching Jim Newkirk's webcast on TDD. He mentioned that during TDD you write a test, watch it fail, and then write the simplest code possible to pass a test, even if you know the code is way too simplistic and will need to be changed in the future.

Can you think of a better way to follow the core principle's of TDD than after a few beers? I can gurantee that after a couple of beers all my tests will initially fail and my class methods will only return primitive types :)
# July 16, 2004 5:40 AM

Anonymoose said:

Simcity 2000 for DOS.
# July 16, 2004 6:02 AM

Darrell said:

David, maybe it should be Test Drinking Development?
# July 16, 2004 6:23 AM

Darrell said:

Jason - yeah I like Britney! She's hot, and sings well too! :D
# July 16, 2004 6:24 AM

Steve Hebert said:

Back in the fall of 1990, I was writing a medical billing system in FoxPro 1.0. On my customer screen, I wanted a history of all charges on the account and that really required a multi-column list box (charge id, charge description, qty, cost, etc.). At that time, FoxPro didn’t have a listbox as we know it today, much less something multi-column.

I was at the bar until closing time drinking a lot more beer than I care to (or can) remember. I ended up back at my apartment alone (so it wasn’t THAT great of a night) and tried going to bed. I couldn’t sleep and I started thinking about that listbox. I thought to myself – I can write this. Now I think the belief you are capable of doing anything is actually one of the advanced stages of drunkenness. I kept drinking because I knew if I stopped, I’d get too tired to continue. After an hour and half I had a working (or so I thought) model complete with a highlight bar that moved up and down, the data scrolled and everything was right with the world. I fell fast asleep on the couch.

The next day I had to recover from my hangover so that evening I sat down to see how it ran. Well the code drew the line properly and managed some of the up and down cursor movement and scrolling. I say some because I think it only worked in one direction but it started hopping over records when it scrolled. And the code blew up more often that it worked. I spent a full day tearing apart that code and rebuilding it, but some of the basic structure stayed the same.
# July 16, 2004 11:11 AM

Steve Hebert said:

"Lightweights always make for great entertainment." - Truer words have never been spoken!
# July 16, 2004 11:22 AM

Darrell said:

FoxPro - Steve you are a much more experienced person than I! I only messed around with it a little when we had to interface with a government system.
# July 18, 2004 9:58 AM

Steve Hebert said:

I am lucky! I always display my FoxPro experience in a 24pt bold/italic font on the top of my resume. Whenever I see a post where people are arguing about which language is best, I'm tempted to jump in with "the greatest language ever was FoxPro 2.6" and try to say it with a straight face.

A government system? It seems like FoxPro always pops up in the strangest places.
# July 19, 2004 4:29 AM

Darrell said:

Yep. It was quite interesting figuring out how to use it and interact with it! :)
# July 19, 2004 6:42 AM

Dave Brookes said:

Fix 1 - Check code in SCS Friday lunch and start from that revision on Monday no matter what.

Fix 2 - Keep drinkin until too bladdered to work again for 2 days.

Fix 3 - Switch careers. Work for Guiness.
# July 19, 2004 8:42 PM

Darrell said:

Work for Guiness, I like that. Or one of those micro-breweries!
# July 20, 2004 2:04 AM

Steve Hebert said:

Wow! This guy (http://guessman.blogspot.com/) just slammed me based on this post. Although he mistook me for a french-man - it looks like the guessman guessed wrong. Preparing response...
# July 20, 2004 8:15 AM

Darrell said:

Steve - I'm not sure I understand his post. It doesn't seem like a slam? Or maybe he changed it since you posted.
# July 20, 2004 8:32 AM

Steve Hebert said:

It's a funny slam. He sets up the quotes saying "(but at the same time, what do those French know...."


# July 20, 2004 10:08 AM

Darrell said:

Ah, I see now!
# July 20, 2004 10:14 AM

secretGeek said:

You crazy alcoholic ranters have shown up in my referer log.... now put down that drink and get back to work you ninnies!

(ok, i admit i've coded under the influence at times, more than a few times really, and find a terrible habit of writing frameworks within frameworks... shooting off on tangents that seem to be aimed at making the code ultra-reusable... and yes, peppering it all the while with some piss-funny 'todo' and 'hack' tokens... i worked on a project in london where the original developer claims he wrote it all while stoned. there's some evidence of this in the code (strange extensibility techniques, and one hilarious easter egg). the program is used by many large european banks and he's a multi-millionaire now. such is life.)

# July 20, 2004 12:22 PM

Darrell said:

I've been visited by secretGeek. Coolness!
# July 21, 2004 1:39 AM

Justin said:

C#, the C is short for Cabernet right?
# July 21, 2004 8:48 AM

Jason Row said:

How appropriate of secretGeek to have a "I'll be drunk" Tech-Ed 2004 image on his site when I visited from his comment.

# July 21, 2004 2:45 PM

Steve Maine said:

The coolest piece of code I've ever written while in an altered state was a piece of OpenGL code I wrote for a graphics class in college.

It was a sort of psychedelic screensaver thing -- an intertwined, counter-rotating system of spheres that exhibited symmetric, simultaneous motion in several different directions at once. It looked pretty sweet, but sort of tended to induce motion sickness.

Anyway, the only way I could get all the matrix math to work out correctly was to get drunk enough to stop thinking about it. Looking at the code today, I have no idea how it works. But it seemed to make sense when I wrote it, and furthermore -- it worked!
# July 21, 2004 4:11 PM

Darrell said:

Drunk code that worked, the first one yet on this post! At least you get a few demerits for non-readable code. :)
# July 23, 2004 5:11 AM

zac said:

um this may me a dumb qestions but what is a drunk code?
# September 30, 2004 12:29 AM

Darrell said:

zac - it's code written when you were either: drinking alcohol or under the influence of legal drugs (such as Sudafed).
# September 30, 2004 1:47 AM
Check out Devlicio.us!

Our Sponsors

Free Tech Publications