
Seriously, if there were no programmers writing code, there would be no bugs. However, hypothesis aside, the number of bugs that you introduce in the software is directly proportional to the amount of code you write. So if you want to avoid bugs, don’t write code. Or rather just write as much code as is really necessary. Following are some of the points that programmers can keep in mind during software development that will help keep the code addition/changes to a minimal and help in maintaining system stability.
1) Keep it simple
“Hmm. This requirement seems interesting. I will use my godlike programming skills and techniques to create code that is fast and consumes minimal memory. Sure it will make the code a bit complex but what the hell as long as it is good.”
Many programmers tend to enjoy writing complex code as a way of showing off their skills. However each line of code that you add could turn out as a potential bug until you have ensured that it is not. So keep the implementation as simple as possible. The easier it is to understand the code, the lesser will be the number of bugs that are introduced. Even if there are bugs they can be easily found by reading and debugging through the simplified code. In short, when writing code, don’t be a lawyer, be a programmer.
2) Avoid unnecessary refactoring
“Hey, who the heck wrote this code? Some of that code seems unnecessary? We don’t need unnecessary stuff like that. Removing this should clean up the code. Ain’t I cool?”
While reading code written by others, programmers are tempted to try and fix what may seem “different” than their style of programming. This type of refactoring can be dangerous because trying to change working code is again a possibility to introduce new bugs. Surely code should be refactored as new changes keep getting added. However this should be a separate effort that should be sorely focussed on refactoring and it should be avoided during the normal development phase.
3) Fix bugs don’t introduce more
“Oh, the bug count is up by five today. No matter, I already know how to fix a couple of them. I’ll just add these patches and we’re done.”
Fixing bugs is always a battle between resolving the earlier ones vs introducing new ones. Many a times the patience of the programmer is tested while fixing bugs because of this balance that has to be maintained. Extra Care has to be taken while fixing bugs so as not to introduce new ones perhaps even more critical than the old ones. Try to fix the bugs with as minimal changes as possible. If major changes are required, analyze if the fix is important enough for the release or it could be postponed to the next release.
Related Posts:
Tags: development


2. Have you heard of TDD? (http://en.wikipedia.org/wiki/Test-driven_development)
[Reply]
Kevin Reply:
July 9th, 2010 at 7:17 pm
Yes Igor, I have heard about TDD. But I have never seen it being used in practice for the projects I worked on. Many organizations and managers in India may not still be comfortable with TDD.
[Reply]