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