views:

216

answers:

1
+4  Q: 

Global Code Review

I have some developers who are rather green when it comes to object oriented development, and I was looking for a way to explain to him the concept of casting and a few other things. I was doing a code review on some of his code and I find things like

   protected Guid LastValue {
       get {
          if (ViewState["LastValue"] == null)
             return Guid.Empty;
          else 
             return new Guid(ViewState["LastValue"].ToString());
       }
       set {
          ViewState["LastValue"] = value;
       }
   }

I would rather he have an understanding of this so I don't need to fix things like this for him all the time.

   protected Guid LastValue {
       get {
          return (Guid)(ViewState["LastValue"] ?? Guid.Empty);
       }
       set {
          ViewState["LastValue"] = value;
       }
   }

In general, for the developer, ToString() see to always be the answer, even if a string is already returned...

i.e.

return Request.QueryString["Value"].ToString();
/sigh

Also, just hardcoding of strings, and

public bool IsOk(string value) {
   if (value.Equals("One") || value.Equals("Two")) return true; else return false;
}

I can fix this code, but if they never go back and look at it, they aren't ever going to know any better.

Usually I would pull this person aside, but they are in China and I'm in the US, so I think some things get lost in translation, so any resources anyone has run across that they found helpful would be great.

Thanks, Dave

+2  A: 

There are a variety of code review tools out there that you can used to facilitate a peer code review that don't require users to be physically in the same office.

By extending it to more than yourself and this developer it makes it seem less targeted and more people learn. I recommend a random selection of code on a regular basis.

The tool that best suits you will depend on your environment but there are plenty of options behind a google search and answers here in SO, e.g. Tool to aid Code Review

MadMurf
+1. There are tools specifically designed for this. Included in the link in the answer are Code Collaborator, Crucible, Review Board, Reitveld, Code Striker and others. Some commercial, some free.
Jason Cohen