Seven Deadly Sins of Programming - #5
[Several readers pointed out that I made a mistake in phraseology, and didn't say the thing I meant. Thanks to them for knowing what I wanted to say more tha I did.]
Thanks to all who have commented on the previous sins, and to those who have written their own lists. I have avoided reading them, but I will take a look when (if...) I get done with my list, and I'll write a summary post linking to them, and likely listing the ones that I would have put on my list if I'd only been a bit smarter and a bit more thoughtful.
Back when I was a pre-teen, I thought I really knew what was going on. I didn't need my parents advice on what to eat, or who to hang around with, and I *certainly* didn't need their advice around oral hygiene.
So I didn't brush my teeth. Oh, I'd rinse my mouth out, but no actual brushing.
This didn't cause any problems - my teeth were fine when I went to the dentist. No worries.
For a year or so. Then I had to have 4 cavities done in one fall. Big cavities. Cavities that weakened my teeth enough that I'm slowly buying my dentist some nice accessories for his boat, as they start to crack and I get crowns put on.
Code hygiene is also important.
Back when I started coding, my teacher (who I am in debt to for being at least 10 years ahead of his time and setting up a real programming curriculum (no, we didn't use abacuses...)) made us write down our programs on paper before we were allowed to use computer time. Not only did you have to write it down, you had to show it to him, and if it wasn't good enough, he'd make you copy it from scratch with the necessary changes.
When I got better, I got introduced to my first text editor. Line oriented, a real improvement. Rather than typing a line over, you could make changes to it.
Then, the fateful day came when I got to use a screen-oriented text editor. You just used the arrow keys, and you could make changes *right in your code*.
Very powerful. And very dangerous, because it supported
COPY AND PASTE
(Cue emphatic and scary music).
Copy and paste is not a sin - it's actually quite a useful thing, but features like it make it far too easy to do bad things. Need a function that's almost like the one you have? Copy and Paste. Need to add another conditional into that double-nested loop? Just insert it in there. Need a class that's almost like what you have? File copy, then search and replace to change the names.
Which leads to too much function complexity and duplication, and to our fifth sin:
Sin #5 - Deferred Refactoring
Once you start deferring refactoring, things get bad. Even if you have good intentions to come back and "clean that up a big", you often don't.
That's why I find agile methods and shared code ownership so interesting. If there are good tests in a codebase, I can find the ugly code that a coworker has written and refactor it into something nicer rather than just trying to get picked to work on "the new codebase"...
Now go brush your teeth, and it wouldn't hurt you to floss sometimes...
Comments
- Anonymous
June 15, 2006
4 big cavities appear in one year?
I've heard of a person going to a dentist and then right after to another and there was a huge difference in what they'd find.
Before settling on one regular dentist permanently it might be good idea to see if another gets same or atleast nearly same results in a normal check of cavities.
I had planned to do so but didn't and now 10 or so drilling and few root canals later I'm feeling quite strongly about getting a second opinion before any more major work. - Anonymous
June 15, 2006
Yes, it's the return of "Picky Paul"...
Surely it's Copy And Paste that's the deadly sin, and as you rightly point out, Cut And Paste can be quite a useful tool if used with caution (a sort of poor man's refactoring). - Anonymous
June 15, 2006
From the last part of the post, does this mean that #4 will be something along the lines of "Misunderstanding Test Driven Development" or "Writing Unit Tests When It's Convenient"? Arrrrrrrrrrrg... - Anonymous
June 16, 2006
Cut and paste is fine
Copy and paste is almost always a sin :) - Anonymous
June 16, 2006
The comment has been removed - Anonymous
June 16, 2006
The comment has been removed - Anonymous
June 16, 2006
I of course puzzled through what your intorduction had to do with the price of beans but then it dawned on me...Early child using PASTE good thing...Programmer misusing PASTE bad thing. Nicely Done. - Anonymous
June 20, 2006
The comment has been removed - Anonymous
July 24, 2006
PingBack from http://technote.thedeveloperside.com/?p=56 - Anonymous
August 04, 2006
So, the time has come for the worst sin.
Just to recap - and so there is one post that lists them all... - Anonymous
August 05, 2006
PingBack from http://www.magerquark.de/blog/archive/374 - Anonymous
August 07, 2006
PingBack from http://pyre.third-bit.com/blog/archives/598.html - Anonymous
October 10, 2006
PingBack from http://bagofbeans.tsangal.org/archives/203