Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code...

15
Creating maintainable code with Code Metrics

Transcript of Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code...

Page 1: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Creating maintainable code with Code Metrics

Page 2: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Introduction to VSTS

Introduction to Visual Studio 2008 Development Edition

Understanding code complexity using Code Metrics

Understanding code complexity using Code Metrics

Page 3: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Visual Studio Team System

Page 4: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Features in Developer Edition

Page 5: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Development Edition Features

Unit testing with code coverageStatic Code AnalysisCode ProfilingCode Metrics

Page 6: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code 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

Page 7: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

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

Page 8: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Performance Report Summary

Page 9: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

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

Page 10: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Metric: Class Coupling# of Dependencies Between Types

Page 11: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Metric: Class InheritanceRipple effect?

Page 12: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

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; }

Page 13: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

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

Page 14: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Overall indication of complexity by aggregation of several factors

Lines of CodeCyclomatic ComplexityComputational Complexity Used on the Windows Code Base

Metric: Maintainability Index

Page 15: Introduction to VSTS Introduction to Visual Studio 2008 Development Edition Understanding code complexity using Code Metrics.

Thank You