I’m not perfect. I know that may shock some of you - but none greater then I. But I want to know what kind of programmer are you.
A quick digression: There have been many metaphors slapped on “software engineering.” I’m not sure where I heard it (I can’t believe I’m the first) but the one that is rollin’ around the ol’ noodle these days is Gardening. A Gardner tends his crops, cares for them by feeding them, and (this is the interesting bit) weeding his garden. It’s a known fact that weeds take from the intended harvest; the harvest is smaller both in quality and quantity. This is why gardners tend, on a daily basis, their crops. But why daily? Because they know the longer they wait the larger the task will be. It’s about maximizing effort through minimized time investment.
Another digression: When you see trash on the ground do you walk on by or do you pick it up and throw it away? Whenever I go to my son’s soccer matches I invariably pick up trash left behind by kids and adults alike. I know I’m not the only one to see the trash on the ground. Maybe it’s my lack of faith in people doing the right thing that makes me see the trash left behind - dunno. Regardless I’m one of say hundreds of people at the soccer match. Why do I do it? Two reasons: 1) it needs to be done and 2) to be a good example for my family.
What does this have to do with writing software? Well, a few things. Allow me to elaborate.
I’ve worked with a lot of different applications and organizations at different points in their lifecycle. And the one thing I’ve noticed is a lack of custodians. We all want to write the new features, or the Next Big Thing (myself included). But when we ignore the trash around us we make maintenance just that much harder for the next guy. What does this trash look like: duplicate code, unformatted code, useless comments, commented out code, and useless if statements (I’m sure more examples can be uncovered but those will do for this conversation).
Improving the quality of a software solution should be every team member’s goal. This is accomplished by writing more tests; thorough tests and not the ones that just assert true. This is also accomplished by writing clean, ‘weed-free’ code. An application will sooner or later enter maintenance mode. It’s bound to happen. If it doesn’t you’re building the wrong solution. As ‘Gardners’ it’s our responsibility to write clean, ‘weed-free’ code not so much for ourselves but for the next guy. Remember, sometimes we’re the Next Guy. Plus we should be cleaning up the code at every given chance. Refactoring comes to mind; that’s what the tests are there for, right?
What do I do? I clean what needs to be cleaned! No hesitation. I didn’t always do that but now that there is the saftey net of Source Control and Unit Tests I’m less worried about my changes breaking something silently.
So - What kind of programmer are you? Do you clean dirty code at every chance or do you walk on by?