Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Coding while drunk

by dws (Chancellor)
on Sep 12, 2002 at 17:56 UTC ( [id://197289]=note: print w/replies, xml ) Need Help??


in reply to Coding while drunk

... and I decided to open a few beers ...I carried on with my coding and after a while solved the problem... but now I'm sober I can't work out why it works

You're using a dangerous definition of "solved".

What you did was stumble across a combination of stuff that "works", but which you don't understand. That's not solving, that's hiding a problem somewhere else.

Set what you have aside, and rewrite. Unless you can get to something you can understand while sober, you're either not done, or you're in over your head.

Replies are listed 'Best First'.
Re: Re: Coding while drunk
by sauoq (Abbot) on Sep 12, 2002 at 19:22 UTC
    What you did was stumble across a combination of stuff that "works", but which you don't understand. That's not solving, that's hiding a problem somewhere else.

    He may have understood it fine when he wrote it. Just because he can't seem to recall that understanding doesn't mean he didn't solve it. We all run into that sooner or later, drunk or not.

    I do agree that he should regain his understanding, test it, fix it if necessary, and probably comment the code. That's the same advice I'd give anyone that had written some code and forgotten how it worked.

    -sauoq
    "My two cents aren't worth a dime.";
    
      Programming languages are meant to communicate a solution to another human through a conversation that a computer is barely smart enough to understand. If you can't even understand your own code, then it doesn't communicate a solution. It may as well have been a bunch of raw hex digits, which would at least be convenient for the computer. I agree with the earlier poster - toss and rewrite. But this time imagine that a sociopathic homicidal maniac who knows where you live will be the next one to have to understand your code.

        I did a a few comp-sci classes at Uni as aprt of a degree that I never finished, any-way one of the lecturer's said (quoting someone else) something that has greatly influenced the way I write code-

        "a program is a letter from one programmer to another that just happens to be understandable by the computer as well"

        I always try and keep that in mind when I program. I don't necessarily agree that Gordy needs to throw away what was written but it certainly needs to be understood, "I get the result I expected" (for all the test conditions I thought of) is far short of good enough.

        --
        Until you've lost your reputation, you never realize what a burden it was or what freedom really is. -Margaret Mitchell

        Programming languages are meant to communicate a solution to another human through a conversation that a computer is barely smart enough to understand.

        I repectfully disagree. Programming languages are abstractions that allow humans to write complex instructions for a computer while remaining isolated from the lower level requirements of the implementation. By the way, no computer is even "barely smart enough to understand" those instructions. Computers just follow them.

        I wasn't really disagreeing with dws in principle. In fact, I agreed that the original poster should regain his understanding of the code. I also suggested that he comment it (for the future) and test it.

        I only disagreed that the code should be discarded out-of-hand simply because the poster was drunk when he wrote it. Of course, if he is unable to regain his understanding, then it should probably be rewritten. That, however, has its own hazards and might come with its own bugs. That brings us back to testing...

        -sauoq
        "My two cents aren't worth a dime.";
        

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://197289]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found