Export (0) Print
Expand All

Global Bank: Coding the New Service, Part 1

Visual Studio 2008

Visual Studio Team System 2008 includes new tools to measure the complexity and maintainability of your code, and provides improved code analysis capabilities to help you write cleaner code. This is the third in a series of articles that will describe a common development scenario at the fictitious Global Bank and show how you can use Visual Studio Team System for your next project. If you're new to the series, you can meet the Global Bank team by reading the introductory article Global Bank: A Scenario for Visual Studio Team System 2008.

Martin, a C# developer, started working at Global Bank directly out of college. In his first year of employment, Martin worked on the Test team, but quickly moved to a full-time development position, which he's held for the last five years. His early experience as a tester has helped him appreciate unit testing and code analysis tools. Martin has Visual Studio Team System 2008 Development Edition installed on his main computer.

Martin receives e-mail from Alice telling him that she has completed the database portion for CDService. He opens his related work item and reviews the notes left for him by Ken, the architect and project manager. Martin synchronizes the GlobalBankDB project, and then builds and deploys GlobalBankDB to his development environment. This technique allows Martin to code against the updates made by Alice while avoiding conflict with other developers who might be working in the database.

Martin first wants to identify any changes in the project since the last time he looked at it, so he opens the CDService project and uses the Compare feature on folders in the project. He also uses the Compare feature to see what's changed in several files he codes in regularly. Martin then checks out CDServices.cs, the file automatically generated by Ken. He then begins to write the code needed to implement CDService based on the architect's design and the database developer's implementation for the SQL Server back-end.

As soon as Martin has finished coding, he checks his code for programming and design issues. First, he looks for Microsoft .NET Framework Design Guidelines rule violations with the Run Code Analysis feature to make sure he meets company guidelines. Martin sees a few performance-related suggestions in the Error List window, which he quickly implements.

Figure 1: Code Analysis Report

Global Bank Code Analysis Report

Next, he presses F5 to debug the Web site. A message appears, indicating that debugging has not been enabled in the web.config file for the site. Martin chooses to modify the web.config file for debugging. After he has stopped the debugger, he reviews the Output window information and then the Error List window for issues. Martin fixes any issues found, and then runs the debugger again to verify his fixes and flush out new errors.

Last, Martin wants to check the complexity and maintainability of his code. He uses the Calculate Code Metrics feature to generate a report listing facts such as the number of lines of code in the project as well as the depth of inheritance. Martin uses the report to fine-tune his code.

Figure 2: Code Metrics Report

Global Bank Code Metrics Results

Because it's nearly time for Martin to head home, he uses the Shelve command to save his work under source control without checking in his changes. Tomorrow he'll finish analyzing and testing his code.

Community Additions

© 2015 Microsoft