One of the greatest aspects of application development is
the plethora of ways to solve a problem. This flexibility affords developers a
lot of creativity. However, it may not be wise to have all your developers
stretching their creative limits at once.

Over time, most organizations adopt best practices and
decide on coding standards to promote a specific development approach. One way
to enforce these standards is through regular peer code reviews. In this week’s
column we examine the code review process and list available tools to aid with
code review and the .NET Framework.

What is code review?

Developers are a finicky bunch, but methodologies like Extreme Programming
(XP) demonstrate that teamwork is essential to successful projects. Code
reviews are one part of teamwork. It promotes the review of one developer’s
code by other team members. Some benefits of code review include:

  • Catches
    more bugs earlier in the software development cycle.
  • Junior
    developers have the opportunity to learn from more experienced peers.
  • Helps
    developers avoid common mistakes.
  • Fosters
    communication among your team.
  • Produces
    code that is easier to maintain.

While it’s easy to list the advantages of code review, it can
be a difficult process to put in motion. Developers, like most people, don’t
appreciate criticism. In addition, code review often seems like extra work,
when in fact it reduces the workload by allowing the team to catch errors
earlier in the development cycle.

Setting and following development standards

Code review is better served if development standards exist
within the organization. Standards tell developers how they must write code;
however, these standards should prevent each developer from using their own
preferred style, while allowing developers some creativity.

One of the benefits of creating standards is that new
developers can adhere to the standard, thus easing their ramp up time. Also,
during code review, it helps developers to have coding standards to refer to as
the ideal state. In addition, if your organization takes advantage of contract
programmers, there is often quick turnaround on the team that can lead to
inconsistent code. A code review of the code ensures consistency.

Code review in action

There are many different ways to handle code reviews—the
approach you use may depend on the size of the development team. The most basic
approach involves one developer reviewing the code of another. This approach is
great due to convenience, but the results can be inconsistent. A second
approach involves a group review where a section of code is presented to the
whole team. This approach yields a lot of input, helping the team as a whole,
but this can be time-consuming to put into action.

Weekly .NET tips in your inbox

TechRepublic’s free .NET newsletter, delivered each Wednesday, contains useful tips and coding examples on topics such as Web services, ASP.NET, ADO.NET, and Visual Studio .NET.

Automatically sign up today!

A key facet of code review is the fact that a developer can
fix a bug written yesterday faster than a bug found in code written a year ago.
The sooner you identify a bug, the easier it is to fix. Also, developers are
more familiar with code they are working on now.

In peer review, developers look at code in small chunks as
features are completed, before it is added to the source control. Looking for a
problem in a single feature is easier than hunting through a mountain of code
as a release date looms ahead.

Another approach involves automation. There are several
tools available that allow developers to review their code as they work.
Automated reviews can happen constantly, allowing violations to be addressed
early in the process before they become entrenched. That is, code is written up
to standard rather than brought up to standard.

Automated reviews also remove egos and personalities from
the review process, making it much more palatable to a wider group of
developers. Furthermore, automated reviews help developers who are new to an
organization’s standards to learn at their own pace, without the potential
embarrassment of having to be told something very simple is wrong by another

Code review tools

There are many available tools to facilitate the code review
process. Some tools automate the process while others facilitate it. A list of
available tools follows:

  • CodeReviewer is a fully integrated code-reviewing
    system. It facilitates peer code review as well as peer-to-peer code
    review buddy tracking.
  • Codestriker
    is an open-sourced Web application that supports online code review. It
    supports various source-code management products and stores all review
    work in a backend database.
  • MZ-Tools include a number of Visual
    Studio .NET add-ons for writing, designing, documenting, and reviewing
  • Aivosto Tools
    provide a set of tools for code optimization and standards enforcement.
  • Code Analyzer
    facilitates checking code for compliance with standards and best
  • DevPartner
    integrates with Visual Studio. It allows you to gauge performance as well
    as standards compliance.

there are numerous tools that help with the review process.

  • FxCop
    is an analysis tool provided by Microsoft. The tool analyzes assemblies to
    ensure that they conform to the .NET Framework Design Guidelines. It comes
    with various rules that may be extended.
  • PrettyCode.Print provides a
    more readable output for code, thus making it easier for developers to
    review offline.
  • WinDiff is a tool for comparing files and
    displaying the results graphically.
  • WinMerge is an open source
    visual text file differencing and merging tool for Windows.

These lists are by no means comprehensive, but they do
provide a peek at what is available.

Code review may help your team

Code reviews are another piece of the software development
cycle. They can be used to reduce development time and deliver more efficient
and stable code that adheres to established standards.

Miss a column?

Check out the .NET Archive, and catch up on the most recent editions of Tony Patton’s column.