Editor’s note: The following MVP Monday post was written by Visual Studio ALM MVP Esteban Garcia
Code reviews are a critical part of software development. Not only do they help you keep you defect-count down, they are also a great way to learn from other people's code. Code reviews also allow teams to communicate changes to the application with their peers.
There have been a few different ways to incorporate code reviews into Visual Studio in the past, including some third party components. For the first time, Visual Studio 2012 includes a Code Review process out of the box by leveraging the Team Foundation Server Work Item Tracking system along with the use of shelvesets. All the information is easily accessible through the redesigned Team Explorer window and Team Foundation Server Web Access. This allows code reviewers to compare code files, annotate them, and send comments back to the requester.
This process is supported through the use of the Work Item tracking system in TFS. Two new Work Item Types were introduced:
- Code review request: when the code review is created, it goes into "requested" state, and when the process is complete is closed.
- Code review response: It gets created when the code review request goes out. If the code reviewer accepts the request it moves to accepted, and when the reviewer completes his or her work, it gets moved to closed.
The fact that Work Items are used opens up a lot of possibilities from a traceability perspective since we now can not only trace the coding task that is associated to a code check-in, but we can also associate all related code reviews.
Now let’s take a look at how this is implemented in Visual Studio 2012. I used the light and dark color schemes to differentiate between the person requesting the code review and the person reviewing the code.
When developers complete coding some functionality, they can click on the “Request code review” link on the Home tab or the My Work tab in Team Explorer:
That brings you to the “New Code Review” dialog where you can enter the following information:
- Name of one or more code reviewer
- Code Review subject
- Area Path
- Code Review Description
You can also list any related work items to the code review. By default, the work items that show up as“In Progress” under the “My Work” tab will show up in this list:
Once the code review is requested, all team members that were entered as reviewers receive an alert. The code reviewer can see all the information about the code review in Team Explorer:
- Who requested it?
- What team members were added as reviewers?
- Related Work Items
- Changed files
The reviewer first signals that he or she is working on the review by clicking on the “Accept” link. This tells other reviewers that the review is already in progress. Then, the reviewer clicks on each changed file and the file comparison window comes up:
The reviewer can annotate this comparison or can add an overall comment from Team Explorer:
All comments are stored with the code review and sent back to the developer that requested the code review. Once the review is complete, the reviewer marks the review as complete by giving it a status of“Looks Good”, “With Comments” or “Needs Work”.
The person that requested the review can now see the Code Review Request work item along with any information entered by the reviewer:
Once the changes are checked in, as you can see here, the Code Review request (ID 1619) is associated to the changeset.
About the author
Esteban Garcia is a Solutions Architect and ALM Consultant at AgileThought, Microsoft Visual Studio ALM MVP, ALM Ranger, Telerik Insider, and president of the Orlando .NET User Group. He has over 13 years of professional experience in software development, working in all phases of distributed object oriented enterprise application development and design using Microsoft technologies. Esteban excels in architecture and best practices and is passionate about Scrum and SDLC improvements using Visual Studio and TFS. Esteban also has a BS degree in Computer Engineering from the University of Central Florida.
The MVP Monday Series is created by Melissa Travers. In this series we work to provide readers with a guest post from an MVP every Monday. Melissa is a Community Program Manager for Dynamics, Excel, Office 365, Platforms and SharePoint in the United States. She has been working with MVPs since her early days as Microsoft Exchange Support Engineer when MVPs would answer all the questions in the old newsgroups before she could get to them