Deborah's Developer MindScape

         Tips and Techniques for Web and .NET developers.

August 28, 2009

Code Reviews

Filed under: C#,VB.NET @ 4:07 pm

A code review is a formal process of reviewing source code with the goal of finding and fixing errors and improving coding techniques. It often results in both improved software quality and in enhanced developer skills.

As part of my consulting services, many software developers and software development teams have hired me to perform code reviews. Whether you implement an internal code review process or hire a consultant, this post details the primary benefits of code reviews.

1. Enhancing Developer Skills

When we were in school, everything we did was reviewed. Every paper we wrote was reviewed and marked up with suggestions to improve our writing skills. Every Math or Computer Science assignment was reviewed and we were given feedback on needed corrections or improvements. All of this review helped us to learn and get better at what we were doing.

This process all but stops when we enter the working world. Sure there are ways we can enhance our development skills by reading blogs and other Web sites, attending seminars, and following the forums. But a code review can provide a much more thorough review of our coding techniques with much more focused suggestions on enhancing our skills.

Say you see this code during a code review:

In C#:

List<int> numberList = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

In VB:

Dim numberList As New List(Of Integer)

You recommend to the developer that the Enumerable class Range method could be used instead:

In C#:

List<int> numberList2 = Enumerable.Range(1, 9).ToList();

In VB:

Dim numberList2 As List(Of Integer) = Enumerable.Range(1, 9).ToList

The team has learned a new technique that will save them time and prevent errors (especially saving typing in the VB case).

2. Learning New Techniques

While the prior topic focused on improving the skills of the reviewee, this benefit focuses on the rest of the team.

It may be that the reviewee used some new technique in their code and shares it with the team during the review process. Or it may be that the reviewer suggests some new techniques while reviewing the code. Either way, the team benefits.

3. Identifying Design Holes/Errors

As we all know, no design is perfect. And with more teams moving to an iterative/agile process, often times the design is more of a guideline.

The code review process can bring to light any questions on business rules, validation, or other possible design holes.

4. Finding Coding Errors

Like me, I’m sure you have at some point written a document, email, or other text, reviewed it, sent it out, and then found some major typographic error that you did not catch.

Same with your code. It is easy to make an error and not notice it as you review your own code, especially if that typo does not result in a syntax error. Code reviews can catch these types of errors.

5. Enhancing the Application Framework

Most teams have (or should have) an application framework, basically a set of base classes and library functions that all of the application’s use. For example, you may have a standard logging class or validation class that you use in every application you develop.

The code review process can help identify where you can make additions or enhancements to your application framework. You may see developers repeating a set of code. This should flag a change to the framework so the developers can call a standard set of code instead of repeating the code each time it is needed.

For example, during the code review, you see this in every form of the application:

In C#:

private void textBox_Enter(object sender,
                            EventArgs e)
    TextBox tb = (TextBox)sender;
    tb.BackColor = Color.BlanchedAlmond;

In VB:

Private Sub TextBox_Enter(ByVal sender As Object, _
                          ByVal e As System.EventArgs) 
    Dim tb As TextBox = DirectCast(sender, TextBox)
    tb.BackColor = Color.BlanchedAlmond
End Sub

With a matching Leave event that resets the color back to the standard color.

This repeated code sends up a flag that you should add this to your base form class and remove it from each form. Then if the users later decide to change the desired background color to Blue, you only have to change it in one place.

6. Improving Code Reuse

Once you have an application framework, it is important for all of the developers on the team to use it to achieve the highest productivity. The code review process can point out where framework classes/methods can be used.

7. Increasing Consistency

If you have a set of programming standards, you can visually inspect that the code meets these standards as part of a code review.

8. Improving Code Quality

Code quality is one of the primary selling points for performing a code review. Improved code is basically the result of all of these other benefits.

By improving the skills of the development team, you improve code quality.

By identifying holes/errors in the design (and fixing them), you improve code quality.

By finding code errors during the review process, you improve code quality.

By building an application framework and using it, you reuse tested code thereby improving code quality.

If you are interested in hiring a consultant to assist with your C# or VB.NET code review, I am offering 20% off for any code review performed between now and October 31, 2009. Just mention this blog for the discount. Contact me at deborahk at or (925)730-1000 for more information.


1 Comment

  1.   Ted — August 31, 2009 @ 4:19 pm    Reply

    Reducing the number of lines of code and improving code documentation are focused on in our code reviews.

RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2017 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs