Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Tools

Code Quality Improvement


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 2: The overall number of violations/KLOC.

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 3: The number of violations with small change impacts/KLOC.

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.

Figure 4: The number of violations with large change impacts/KLOC.

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.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.