I write code as cleanly on the first pass as I do on the last (if there ever is a last). The reason being that if I hacked it and then showed the client/my boss that it's working, it would be hard to justify the additional time to clean it up when they want it pushed to production now.
I blast put the most bogus half-witted garbage that could possibly half work, train of thought style. It just embarrassingly bad. I go back and clean it up almost immediately while it's still fresh in the mind.
The upside is that I usually find I need only 1/3 of what I thought I needed. It doesn't feel quite so bad to throw out huge chunks of stuff I know is so bad I wouldn't want anyone to see it anyway. The worst thing in a project is something I think is really clever but just not needed. I become irrationally attached.
My code starts and stays embarrassingly bad until I need to refactor it. Eventually, the code improves. Very often, though, it gets thrown out entirely. Only profitable code deserves to be good.
Caveat: The above applies to my own business projets where I am the sole coder. I write better code for clients - it still starts out rough, but I refactor more frequently.
But yes, otherwise I find I don't have time to fix it later. Occasionally, when I know there's a better way of doing it but am having trouble thinking of it immediately I throw a # TODO in there.
You should not have a second pass it's a huge time waster. I like taking the extra time to optimize everything from the start. Maybe I won't finish my project within an hour, bu extra time helps as more ideas come to mind while coding
10 comments
[ 3.0 ms ] story [ 32.0 ms ] threadThe upside is that I usually find I need only 1/3 of what I thought I needed. It doesn't feel quite so bad to throw out huge chunks of stuff I know is so bad I wouldn't want anyone to see it anyway. The worst thing in a project is something I think is really clever but just not needed. I become irrationally attached.
Caveat: The above applies to my own business projets where I am the sole coder. I write better code for clients - it still starts out rough, but I refactor more frequently.
But yes, otherwise I find I don't have time to fix it later. Occasionally, when I know there's a better way of doing it but am having trouble thinking of it immediately I throw a # TODO in there.