Information Technology Reference
In-Depth Information
Maintain Organizational Standards with
Code Audits
Coding standards facilitate a common understanding of a code base
among a diverse group of developers. Just like the car maintenance
market has been largely standardized so that you can buy a new head-
light from your manufacturer or any number of third-party vendors, so
too can a code base's “structure” become standardized, which permits
various individuals to quickly assess behavior and modify it as needed.
This makes your response in development faster, and keeps you from
being dependent on one certain developer or team to make changes.
As mentioned earlier, while both human code reviews and pair
programming can be effective in monitoring coding standards, they do
not scale as well as automated tools. Not only do tools contain hun-
dreds of rules (that are usually customizable), they can be run fre-
quently and usually without intervention.
In a CI environment, a code analysis tool can be run any time a
change is made to the project's repository. The tool can analyze an
individual file when it is changed, or analyze the entire code base
when structural or other system changes are made. What's more, due
to the nature of CI, interested parties can be instantly notified of viola-
tions in architecture or coding. For instance, a popular code analysis
tool for the Java platform PMD has more than 180 customizable rules
in categories ranging from braces placement in conditionals to naming
conventions, design conventions (like simplifying conditionals, etc.),
and even unused code. In Java, if a conditional only has one statement
following it, braces are optional. The code in Listing 7-1, for example,
is completely legal in Java. Some organizations, however, find this
code dangerous because later someone may forget to add braces when
adding additional statements.
LISTING 7-1
Simple Conditional without Braces
if(status)
commit();
The code in Listing 7-2 is completely legal; however, there is a
subtle defect that could ensnare an unsuspecting developer who may
 
Search WWH ::




Custom Search