Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: Avoiding silly programming mistakes

by missingthepoint (Friar)
on Aug 21, 2008 at 11:07 UTC ( #705759=note: print w/replies, xml ) Need Help??

in reply to Re: Avoiding silly programming mistakes
in thread Avoiding silly programming mistakes

Your state of mind is the biggest factor in your coding.

The second point also sounds wise, but that first statement resonates very strongly with me. Allow me to share an anecdote...

One evening, back when I was learning C, I'd spent a hour or two reading Snow Crash by Neal Stephenson. Perhaps this primed my mind in some way for what followed. :)

I sat down and began coding... but my 'state of mind' was singular. I don't think I've ever been that focused. I began writing a routine to convert strings containing numbers in arbitrary bases to their numeric values... in Perl terms, this was a super oct().

I spent perhaps two hours total. My mind seemed very clear, and I thought through the problem in depth... I probably spent 20 minutes doing nothing but thinking between brief periods of typing. At the end - I hadn't yet heard of TDD, you see :) - I ran my code and started testing it. It worked the first time. Perfectly. Everything happened exactly as I expected. I made no changes to the code after that, because there were no more to make. My memory's a bit fuzzy, but I think I also had a routine to do the reverse operation, and that worked perfectly too. I was shocked.

I know I've improved since then and today I could probably find an edge case or two to break that code. But at the time, it was an amazing, almost transcendent experience. I couldn't believe I'd produced what I had.

So I concur - it's the biggest factor. This begs the question... What techniques do the monks have for 'focusing'? How do you enter 'deep hack mode'? Perhaps I should start a new thread. :)

email: perl -e 'print scalar reverse map { chr( ord($_)-1 ) } split //, "ufo/hojsfufqAofc";'
  • Comment on Re^2: Avoiding silly programming mistakes

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://705759]
and a moth chases the moon...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-03-30 20:08 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (364 votes). Check out past polls.