Experiences Using the Checker
Applying a coding standards checker reduces coding standards violations during implementation. However, the number of violations detected and eliminated depends on the characteristics of the target project and the quality of the coding standards rules. We found that each project has similar overall trends but many different details that impact coding standards checking. Thus, the following results should be viewed as a trend, not in a deterministic manner.
Direct benefits refer to how reducing the number of violations improved code quality. Indirect benefits are other unexpected developer benefits.
Figure 2 shows the overall trend for the number of coding standards violations. To eliminate the effects of rule evolution, we use the latest rule set for all checking. After a relatively steady number of violations between Nov-04 and Jan-05, there was a violation reduction of approximately 1/8 in Feb-05. There was an unexpected increase in violations between Feb-05 and Mar-05, but this was acceptable because the target project was evolving continuously.
Figure 3 shows the trend for the number of violations whose corrections impact only the current module. Violations decreased 6.6 percent since the date of checker deployment. This data does not cover comment rules, which usually don't have large change impacts but do require significant change efforts.
Figure 4 shows the trend for the number of violations whose corrections impact more than the current module. Violations decreased 19.6 percent since the date of checker deployment.
One of the unexpected benefits of coding standards checking was the developer education it promoted. Beginners, and even some experienced developers, initially did not understand the meaning and importance of some coding standards items. For example, consider the coding standards item "Prefer initializations to assignments," which is known as an efficient way to initialize member variables in a constructor (see Effective C++, by Scott Meyers; Addison-Wesley, 1992). Some developers did not understand why initializing members in a constructor's initialization list is better than assigning the initial values in a constructor's body. They discussed these issues when reviewing the checker's results. This eventually helped the developers understand C++ features thoroughly, and demonstrates how coding standards checking helps developers learn from their mistakes.
Another indirect benefit was the removal of unrealistic coding standards items. When we applied the coding standards rules to the Mobile project, we found that most developers did not obey the rule "Do not exceed 80 columns per line." This rule was developed because some old development environments had 80-column displays. We examined our development environments and concluded that in our situation, such limited development environments are rarely used and longer columns are preferred. Consequently, we changed the column limitation from 80 to 150 columns per line. This kind of coding standards modification has improved developer buy-in to coding standards compliance.