January 10, 2013

Lightweight Code Review in Visual Studio


One of the hidden gems in P4VS, the Perforce Visual Studio plug-in, is using shelves for a simple code review system. It's easy, you don't need any extra tools, and there's a little enhancement coming in the next P4VS version in the next few weeks.

Let's say I've got a few files checked out in P4VS:

code review perforce visual studio

I'd like to have someone review the new C# file I'm working on, Program.cs. I'll add that file to a shelf:


P4VS will walk me through creating a new shelf. Notice that the new shelf looks like it has two copies of Program.cs. One is my local checked out copy, and another is the shelved copy.


Before I can send this shelf to someone else for review, I need to move my local checked out copy to a different changelist.


Once I've done that, I can send this shelf to earlfor review.


I can browse a list of users or just send it to earldirectly if I remember his user name.


That's it! Now earl can do anything he wants with the changelist: look at my changes, get the files into his workspace for build and test, and so on. And that's the little enhancement that's coming in the next P4VS version: inside P4VS I'll be able to look at the shelved files directly, without unshelving them.

Code review is so helpful that it's a daily part of work for a lot of developers. But if it's something you do a few times a day, it should be quick and painless. Try out shelving in P4VS for a lightweight code review system and I think you'll be happy with the results. If you don't have P4VS, or you want to upgrade to the latest version, just look for it in the Visual Studio Extension Gallery.