View
244
Download
0
Category
Tags:
Preview:
Citation preview
Creating maintainable code with Code Metrics
Introduction to VSTS
Introduction to Visual Studio 2008 Development Edition
Understanding code complexity using Code Metrics
Understanding code complexity using Code Metrics
Visual Studio Team System
Features in Developer Edition
Development Edition Features
Unit testing with code coverageStatic Code AnalysisCode ProfilingCode Metrics
Integrated Unit Testing
Integrated Static Code analysisSecurity ErrorsLocalization problemsMemory issues…
Integrated ProfilerPerformance problemsMemory problems
Potential Sql Injection attack
Object not Disposed
Localization Issue
Improving Code Quality
Who allocates the most Objects
Who allocates the most memory
Who is called the most?
Who runs for the longest
What do you have the most of?
What is taking up the most memory
Improving Quality: Profiler
Performance Report Summary
Gives a snapshot of software healthUnderstand your code complexityQuickly compare code to find potential trouble spots
Reduce risk & improve maintainabilityUnderstand complexity of inherited code
Code metrics
Metric: Class Coupling# of Dependencies Between Types
Metric: Class InheritanceRipple effect?
Metric: Lines of Code# of Executing Lines of Code
123
4
5
static class Program{
#region Application Entry Point/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main(string[] args){
Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Workflow(args);
}#endregion
#region Static Methods/// <summary> Primary workflow for the application. </summary>/// <param name="args"> Command line arguments. </param>private static void Workflow(string[] cmdargs){
// Collect the list of command line argumentsList<string> args = new List<string>(cmdargs);
// Show usage syntax if the user so asksif (UseArg(args, "/?")) { ShowAbout(); return; }
12
3
45
6,7
89
10
11
bool ParseCommandLine(string[] args){
if (args.Length == 0) ShowHelp(); return;for (int i = 0; i < args.Length; i++)
switch (args[i]){
case "/?" :ShowHelp();return false;
case "/input" :if (args.Length > i && File.Exists(args[i + 1]))
InputFile = args[i++];break;
case "/c" :Colapse = true;break;
}return true;
}
Metric: Cyclomatic Complexity# of branches of Code
Overall indication of complexity by aggregation of several factors
Lines of CodeCyclomatic ComplexityComputational Complexity Used on the Windows Code Base
Metric: Maintainability Index
Thank You
Recommended