Tuesday, July 1, 2014

The Boy Scout Rule?

As a developer, you should be constantly making improvements to your code over time to make it better.  This can include refactoring, which is the restructuring of code without changing the external behavior, or keeping current with versions of the framework you are using.

A good approach to refactoring is called The Boy Scout Rule.  The Boy Scout Rule as it relates to coding basically means that when you check your code in, it should be in a better place or cleaner than when you checked it out.

Another approach related to refactoring is something that I noticed developers practicing and it is a term that I call The Community Service Rule.  I'm not sure if this name has been used by someone else or if there is another term for it, but my definition of this rule is going out and searching through lines of code to find something to fix and make better, but the code you change is not something that is related to a specific reported bug or feature.  This rule is one that I do not agree with in a corporate environment and one that I do not follow unless it is in a personal project of my own.    

The main difference that I see in both of these approaches is the use of a QA team that is employed to test specific bugs or features.  When you are using the Boy Scout Rule, you are guaranteed that another set of eyes will be on that part of code that you refactored, because it is code that you are already touching that is related to a specific bug or feature. The Community Service Rule, however, is code that is not usually related to a bug or feature and not explicitely tied to a bug or feature.  This is a problem in my eyes and may cause more production bugs because the code is not tested by someone else.  Worse things may happen, like a production outage which may cost your company money and you money in the long run if your change that you made caused it.

This is a debate that I have with other developers where I currently work and there are developers on each side of the fence.  It is a topic that should be discussed among your development teams with an outcome of some sort of guideline created.

peace yo!