What Careless Code Says

What Careless Code Says

Mike Jansen
Mike Jansen

March 26, 2012

There is a certain type of bug that, when it appears as a result of my code, causes me deep embarrassment.

This type of bug isn't caused by missed or misunderstood acceptance criteria, although those are frustrating for different reasons. Bugs that occur only when the wind is blowing a certain way are irksome, but sometimes can't be helped.

The type of bug I'm referring to are the ones brought by laziness, sloppiness, or a lack of time spent on the feature in the name of getting things done quickly.

When someone finds a bug like this in my code, it is almost always because of a moment of carelessness. At some point I try to rush in order to move on, and I can usually see in the code where it happened - a method doing a little too much, a poorly named class, or messy unit tests that ache for refactoring.

I'm not just upset because it will take me time to fix it, but also because of the groups of people it will affect. My client may be forgiving, but it takes time to test and deploy the fix, and if it happens often enough, it degrades my credibility.

Of course, users are affected as well - software that doesn't behave as expected is software that tends not to be used.

The Effects of Careless Code on a Team

In a team setting, however, what may be the most embarrassing to me is the effect on my team. Time I spend fixing my own bugs detracts from my ability to contribute that week, but that itself hardly compares to having someone else come across my carelessness.

Careless code doesn't just lead to bugs. Code that is poorly designed, unreadable, or untested may not affect clients and users right away, but the team sees it and feels its effects the next time requirements change.

Not only does this type of code cost my team members time, it says that I'm more concerned with getting things done quickly instead of right. The code says that I don't mind if someone else has to spend extra time to clean up after me.

My careless code says that their time is less valuable than mine.

Avoiding Careless Code

My code doesn't mean to say such nasty things. Often when I get careless, I'm frustrated and tired and just want to move on. What I need to do in those situation is to take a break, clear my head, get help if I need it, and sit down to do things right instead of plowing forward.

A great way to avoid carelessness is to pair - I am far less likely to get away with lazy implementations if someone is there to help me out and keep me accountable.

I've worked on many teams where someone is feeling overworked and is trying to get too much done at once. These things happen, and on a good team people will help pick up the slack and move past a single incident. However, if it's a recurring theme, it can cause distrust among the team and generally make everyone's lives more miserable.

If you find yourself in a situation when you're trying to just "get it done", think about the rest of your team. The investment in getting it right the first time will continue to pay dividends over time.