SlideShare a Scribd company logo
Ensure code quality with vs2012
Sandeep Joshi
I.   Quality Demystified

II. Code Analysis in VS2012

III. Code Metrics and Maintainability

IV. Code Coverage

V. Code Clone Analysis

VI. Q & A
 Quality is often non measurable
   ‘Code that smells’

   Proper Solution vs. Quick Fix

 Better crafted software
   Drive quality ‘upstream’

      By following proven processes

      By Behavioral Changes
Release




              Test



Development
Release




              Test



Development
 Find Problems before you make them
   Code Analysis
   Code Metrics
   Code Clone Analysis
 Don’t let bugs out of your sight
   Unit Testing and Code Coverage
   Test Impact Analysis
   Coded UI Tests
   Performance Tests
 Don’t let bugs get into your builds
   Gated Check-In
void               wchar_t                     wchar_t

       wchar_t
                              sizeof                  "%s: %sn"
 warning C6057: Buffer overrun due to number of characters/number
 of bytes mismatch in call to 'swprintf_s'

void               wchar_t                     wchar_t

    wchar_t
                               _countof
protected void Page_Load(object sender, EventArgs e)
 {
     string userName = Request.Params["UserName"];
     string commandText = "SELECT * FROM Contacts
                          WHERE ContactFor =
                          '" + userName + "'";

         SqlCommand command = new SqlCommand
CA2100 : Microsoft.Security : The query string passed to       (commandText,
System.Data.SqlClient.SqlCommand..ctor in Page_Load could containthis.connection);
                                                                 the following variables
this.get_Request().get_Params().get_Item(...). If any of these variables could come from user input, consider using a
stored procedure or a parameterized SQLreader of building the query with string concatenations.
           SqlDataReader query instead = command.ExecuteReader();

          while (reader.Read())
          {
            ListBox1.Items.Add
                           (new ListItem
                           (reader.GetString(0)));
          }
 }
protected void Page_Load(object sender, EventArgs e)
{
    string userName = Request.Params["UserName"];
    string commandText = "SELECT * FROM Contacts
                         WHERE ContactFor =
                         @userName";
    SqlCommand command = new SqlCommand
                             (commandText,
                              connection);

    command.Parameters.Add(new SqlParameter
                          ("@userName", userName));

    SqlDataReader reader = command.ExecuteReader();
    while (reader.Read())
    {
       ListBox1.Items.Add
                      (new
                       ListItem(reader.GetString(2)));
    }
}
Ensure code quality with vs2012
public class EquationBuilder
{
    public override string ToString()
    {
        string result = CalculateResult().ToString();
        switch (operatorKind)
        {
            case EquationOperator.Add:
                return left + " + " + right +
                           " = " + result;
            case EquationOperator.Subtract:
                return left + " - " + right +
                           " = " + result;
            default:
                throw new NotImplementedException();
        }
    }

    …
}
public void DisplayMultiplyResult()
{
     EquationBuilder equation =
        new EquationBuilder
        (left,
         EquationBuilder.EquationOperator.Multiply,
         right);
    ResultsBox.Text = equation.ToString();
}
public class EquationBuilder
{
    public override string ToString()
    {
        string result = CalculateResult().ToString();
                switch (operatorKind)
                {
                        case EquationOperator.Add:
                                 return left + " + " + right +
                                                         " = " + result;
                        case EquationOperator.Subtract:
                                 return left + " - " + right +
                                                         " = " + result;
                        default:
                                 throw new NotImplementedException();
    CA1065 : Microsoft.Design : 'Class1.ToString()' creates an exception of
                }
    type}
        'NotImplementedException'. Exceptions should not be raised in
    this type of method. If this exception instance might be raised, change
         …
    this method's logic so it no longer raises an exception.
}
public class EquationBuilder
{
    public override string ToString()
    {
        string result = CalculateResult().ToString();
        switch (operatorKind)
        {
            case EquationOperator.Add:
                return left + " + " + right +
                           " = " + result;
            case EquationOperator.Subtract:
                return left + " - " + right +
                           " = " + result;
            default:
                 Debug.Assert(false,
                              "Unexpected operator!");
                return "Unknown";
        }
   }

   …
void TraceInformation(char *message,
                       int &totalMessages)
{
    // Only print messages if there are
    // more than 100 of them or the trace
    // settings are set to verbose
     if (TRACE_LEVEL > 3 ||
         totalMessages++ > 100)
     {
          printf(message);
     }
}
    warning C6286: (<non-zero constant> || <expression>) is always a non-zero constant.
               <expression> is never evaluated and might have side effects
void TraceInformation(char *message,
                       int &totalMessages)
{
    // Only print messages if there are
    // more than 100 of them or the trace
    // settings are set to verbose
    totalMessages++;
    if (TRACE_LEVEL > 3 ||
        totalMessages > 100)
    {
         printf(message);
    }
}
public FldBrwserDlgExForm():
       SomeSystem.SomeWindows.SomeForms.SomeForm
{
  CA1704 : Microsoft.Naming : Correct the spelling of new in member name 'rtb.AcpectsTabs‘
       this.opnFilDlg = 'Acpects' opnFilDlg();
  CA1704 : Microsoft.Naming : Correct the spelling of 'Brwser' in new fldrBrwsrDlg1();
       this.fldrBrwsrDlg1 = type name 'FldBrwserDlgExForm'.
       this.rtb = new rtb();
  CA1704 : Correct the spelling of 'Brwsr' in type name 'fldrBrwsrDlg1'.
       this.opnFilDlg.DfltExt = "rtf";
       this.desc = "Select the dir you want to use as
  CA1704 : Correct the spelling of 'Btn' in member name 'fldrBrwsrDlg1.ShowNewFldrBtn’
                                             default";
  CA1704 : Correct the spelling of 'desc' in member name 'FldBrwserDlgExForm.desc'
       this.fldrBrwsrDlg1.ShowNewFldrBtn = false;
       this.rtb.AcpectsTabs = true;
  CA1704 : Correct the spelling of 'Dflt' in member name 'opnFilDlg.DfltExt'
} CA1704 : Correct the spelling of 'Dlg' in type name 'FldBrwserDlgExForm'.
   CA1704 : Correct the spelling of 'Fil' in type name 'opnFilDlg'.

   CA1704 : Correct the spelling of 'Fld' in type name 'FldBrwserDlgExForm'.

   CA1704 : Microsoft.Naming : Correct the spelling of 'opn' in type name 'opnFilDlg'.

   CA1704 : Microsoft.Naming : Correct the spelling of 'rtb' in type name 'rtb'.
public class FolderBrowserDialogExampleForm :
     System.Windows.Forms.Form
{
     // Constructor.
    public FolderBrowserDialogExampleForm()
    {
        this.openFileDialog1 = new OpenFileDialog();
        this.folderBrowserDialog1 = new FolderBrowserDialog();
        this.richTextBox1 = new RichTextBox();
        this.openFileDialog1.DefaultExt = "rtf";
        // Set the help text description
        this.folderBrowserDialog1.Description =
               "Select the directory that you want to use
                as the default.";
        // Do not allow the user to create new files
        this.folderBrowserDialog1.ShowNewFolderButton = false;
        this.richTextBox1.AcceptsTab = true;
    }
}
demo
Ensure code quality with vs2012
Maintainability   Cyclomatic   Class Coupling
         Index             Complexity

Green    > 60              < 10         < 20
Yellow   40 - 60           10 - 15
Red      < 40              > 15         > 20
Ensure code quality with vs2012
demo
Ensure code quality with vs2012
demo
Ensure code quality with vs2012
Ensure code quality with vs2012
Ensure code quality with vs2012
Ad

More Related Content

What's hot (20)

Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
yohanbeschi
 
Spock framework
Spock frameworkSpock framework
Spock framework
Djair Carvalho
 
The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
Dror Helper
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
Christoffer Noring
 
Jason parsing
Jason parsingJason parsing
Jason parsing
parallelminder
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
Dror Helper
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
Christoffer Noring
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
Darwin Durand
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
Robert MacLean
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniques
David Rodenas
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5
Kim Hunmin
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
Jussi Pohjolainen
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
JOYITAKUNDU1
 
ES3-2020-06 Test Driven Development (TDD)
ES3-2020-06 Test Driven Development (TDD)ES3-2020-06 Test Driven Development (TDD)
ES3-2020-06 Test Driven Development (TDD)
David Rodenas
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
LogeekNightUkraine
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Ryosuke Uchitate
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements II
Reem Alattas
 
Codeofdatabase
CodeofdatabaseCodeofdatabase
Codeofdatabase
koushikdewan
 
Java 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR BeneluxJava 8 - Nuts and Bold - SFEIR Benelux
Java 8 - Nuts and Bold - SFEIR Benelux
yohanbeschi
 
The secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you aboutThe secret unit testing tools no one ever told you about
The secret unit testing tools no one ever told you about
Dror Helper
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
Tomek Kaczanowski
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
Dror Helper
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
Darwin Durand
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
Robert MacLean
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniques
David Rodenas
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5
Kim Hunmin
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
JOYITAKUNDU1
 
ES3-2020-06 Test Driven Development (TDD)
ES3-2020-06 Test Driven Development (TDD)ES3-2020-06 Test Driven Development (TDD)
ES3-2020-06 Test Driven Development (TDD)
David Rodenas
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17Alexey Tsoy Meta Programming in C++ 16.11.17
Alexey Tsoy Meta Programming in C++ 16.11.17
LogeekNightUkraine
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Ryosuke Uchitate
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements II
Reem Alattas
 

Viewers also liked (20)

Kina Affarer Nr 19 07
Kina Affarer Nr 19 07Kina Affarer Nr 19 07
Kina Affarer Nr 19 07
bjorn_odenbro
 
Bgt4
Bgt4Bgt4
Bgt4
Prafulla Tekriwal
 
TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011
TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011
TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011
Technopreneurs Association of Malaysia
 
Cets 2014 hybert tips legal effective graphics
Cets 2014 hybert tips legal effective graphicsCets 2014 hybert tips legal effective graphics
Cets 2014 hybert tips legal effective graphics
Chicago eLearning & Technology Showcase
 
My Personality Development
My Personality DevelopmentMy Personality Development
My Personality Development
Dr. Muhammad Iqbal
 
Career Planning - Job Application
Career Planning - Job ApplicationCareer Planning - Job Application
Career Planning - Job Application
Dr. Muhammad Iqbal
 
Social Media Strategy - Moving Beyond the "How to"
Social Media Strategy - Moving Beyond the "How to"Social Media Strategy - Moving Beyond the "How to"
Social Media Strategy - Moving Beyond the "How to"
John Chen
 
INVESTOR INFORMATION SUMMARY
INVESTOR INFORMATION SUMMARYINVESTOR INFORMATION SUMMARY
INVESTOR INFORMATION SUMMARY
MUSA Sir DR IR FEROZ
 
Dr. s.n.-khan (1)
Dr. s.n.-khan (1)Dr. s.n.-khan (1)
Dr. s.n.-khan (1)
Prafulla Tekriwal
 
Hadoop基线选定
Hadoop基线选定Hadoop基线选定
Hadoop基线选定
baggioss
 
How to code
How to codeHow to code
How to code
Shishir Sharma
 
투이컨설팅 제34회 Y세미나 : 설문결과
투이컨설팅 제34회 Y세미나 : 설문결과투이컨설팅 제34회 Y세미나 : 설문결과
투이컨설팅 제34회 Y세미나 : 설문결과
2econsulting
 
Ambush marketing
Ambush marketingAmbush marketing
Ambush marketing
Prafulla Tekriwal
 
Groesch symbiosis by kelvin groesch 3.4.11
Groesch symbiosis by kelvin groesch 3.4.11Groesch symbiosis by kelvin groesch 3.4.11
Groesch symbiosis by kelvin groesch 3.4.11
LM9
 
CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...
CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...
CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...
Chicago eLearning & Technology Showcase
 
Hdfs
HdfsHdfs
Hdfs
baggioss
 
Music : your social media optimisation
Music : your social media optimisationMusic : your social media optimisation
Music : your social media optimisation
af83media
 
Getting Results With Usability Testing (5Q GROK Webinar Series)
Getting Results With Usability Testing (5Q GROK Webinar Series)Getting Results With Usability Testing (5Q GROK Webinar Series)
Getting Results With Usability Testing (5Q GROK Webinar Series)
Five Q
 
Cets 2015 ls fortney to gamify or not
Cets 2015 ls fortney to gamify or notCets 2015 ls fortney to gamify or not
Cets 2015 ls fortney to gamify or not
Chicago eLearning & Technology Showcase
 
CETS 2011, Eric Sanders, slides for Training via Online Discussions
CETS 2011, Eric Sanders, slides for Training via Online DiscussionsCETS 2011, Eric Sanders, slides for Training via Online Discussions
CETS 2011, Eric Sanders, slides for Training via Online Discussions
Chicago eLearning & Technology Showcase
 
Kina Affarer Nr 19 07
Kina Affarer Nr 19 07Kina Affarer Nr 19 07
Kina Affarer Nr 19 07
bjorn_odenbro
 
TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011
TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011
TeAM and iSentric - Mobile Business Commercialization Program - 31st Mar 2011
Technopreneurs Association of Malaysia
 
Career Planning - Job Application
Career Planning - Job ApplicationCareer Planning - Job Application
Career Planning - Job Application
Dr. Muhammad Iqbal
 
Social Media Strategy - Moving Beyond the "How to"
Social Media Strategy - Moving Beyond the "How to"Social Media Strategy - Moving Beyond the "How to"
Social Media Strategy - Moving Beyond the "How to"
John Chen
 
Hadoop基线选定
Hadoop基线选定Hadoop基线选定
Hadoop基线选定
baggioss
 
투이컨설팅 제34회 Y세미나 : 설문결과
투이컨설팅 제34회 Y세미나 : 설문결과투이컨설팅 제34회 Y세미나 : 설문결과
투이컨설팅 제34회 Y세미나 : 설문결과
2econsulting
 
Groesch symbiosis by kelvin groesch 3.4.11
Groesch symbiosis by kelvin groesch 3.4.11Groesch symbiosis by kelvin groesch 3.4.11
Groesch symbiosis by kelvin groesch 3.4.11
LM9
 
CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...
CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...
CETS 2011, Jennifer De Vries, slides for Defusing Landmines in eLearning Proj...
Chicago eLearning & Technology Showcase
 
Music : your social media optimisation
Music : your social media optimisationMusic : your social media optimisation
Music : your social media optimisation
af83media
 
Getting Results With Usability Testing (5Q GROK Webinar Series)
Getting Results With Usability Testing (5Q GROK Webinar Series)Getting Results With Usability Testing (5Q GROK Webinar Series)
Getting Results With Usability Testing (5Q GROK Webinar Series)
Five Q
 
Ad

Similar to Ensure code quality with vs2012 (20)

Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
PVS-Studio
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
varadasuren
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
Natasha Murashev
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
Ara Pehlivanian
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
Jafar Nesargi
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
Alex Tumanoff
 
Clean code
Clean codeClean code
Clean code
Arturo Herrero
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Lucidworks
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
John Ferguson Smart Limited
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
JAXLondon_Conference
 
Exception
ExceptionException
Exception
Sandeep Chawla
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
SOLID Java Code
SOLID Java CodeSOLID Java Code
SOLID Java Code
Omar Bashir
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
Olexandra Dmytrenko
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
PVS-Studio
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
sameer farooq
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
Natasha Murashev
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
Ara Pehlivanian
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
Woody Pewitt
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Lucidworks
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
arihantmum
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
Abed Bukhari
 
Ad

Recently uploaded (20)

Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 

Ensure code quality with vs2012

  • 3. I. Quality Demystified II. Code Analysis in VS2012 III. Code Metrics and Maintainability IV. Code Coverage V. Code Clone Analysis VI. Q & A
  • 4.  Quality is often non measurable  ‘Code that smells’  Proper Solution vs. Quick Fix  Better crafted software  Drive quality ‘upstream’  By following proven processes  By Behavioral Changes
  • 5. Release Test Development
  • 6. Release Test Development
  • 7.  Find Problems before you make them  Code Analysis  Code Metrics  Code Clone Analysis  Don’t let bugs out of your sight  Unit Testing and Code Coverage  Test Impact Analysis  Coded UI Tests  Performance Tests  Don’t let bugs get into your builds  Gated Check-In
  • 8. void wchar_t wchar_t wchar_t sizeof "%s: %sn" warning C6057: Buffer overrun due to number of characters/number of bytes mismatch in call to 'swprintf_s' void wchar_t wchar_t wchar_t _countof
  • 9. protected void Page_Load(object sender, EventArgs e) { string userName = Request.Params["UserName"]; string commandText = "SELECT * FROM Contacts WHERE ContactFor = '" + userName + "'"; SqlCommand command = new SqlCommand CA2100 : Microsoft.Security : The query string passed to (commandText, System.Data.SqlClient.SqlCommand..ctor in Page_Load could containthis.connection); the following variables this.get_Request().get_Params().get_Item(...). If any of these variables could come from user input, consider using a stored procedure or a parameterized SQLreader of building the query with string concatenations. SqlDataReader query instead = command.ExecuteReader(); while (reader.Read()) { ListBox1.Items.Add (new ListItem (reader.GetString(0))); } }
  • 10. protected void Page_Load(object sender, EventArgs e) { string userName = Request.Params["UserName"]; string commandText = "SELECT * FROM Contacts WHERE ContactFor = @userName"; SqlCommand command = new SqlCommand (commandText, connection); command.Parameters.Add(new SqlParameter ("@userName", userName)); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { ListBox1.Items.Add (new ListItem(reader.GetString(2))); } }
  • 12. public class EquationBuilder { public override string ToString() { string result = CalculateResult().ToString(); switch (operatorKind) { case EquationOperator.Add: return left + " + " + right + " = " + result; case EquationOperator.Subtract: return left + " - " + right + " = " + result; default: throw new NotImplementedException(); } } … }
  • 13. public void DisplayMultiplyResult() { EquationBuilder equation = new EquationBuilder (left, EquationBuilder.EquationOperator.Multiply, right); ResultsBox.Text = equation.ToString(); }
  • 14. public class EquationBuilder { public override string ToString() { string result = CalculateResult().ToString(); switch (operatorKind) { case EquationOperator.Add: return left + " + " + right + " = " + result; case EquationOperator.Subtract: return left + " - " + right + " = " + result; default: throw new NotImplementedException(); CA1065 : Microsoft.Design : 'Class1.ToString()' creates an exception of } type} 'NotImplementedException'. Exceptions should not be raised in this type of method. If this exception instance might be raised, change … this method's logic so it no longer raises an exception. }
  • 15. public class EquationBuilder { public override string ToString() { string result = CalculateResult().ToString(); switch (operatorKind) { case EquationOperator.Add: return left + " + " + right + " = " + result; case EquationOperator.Subtract: return left + " - " + right + " = " + result; default: Debug.Assert(false, "Unexpected operator!"); return "Unknown"; } } …
  • 16. void TraceInformation(char *message, int &totalMessages) { // Only print messages if there are // more than 100 of them or the trace // settings are set to verbose if (TRACE_LEVEL > 3 || totalMessages++ > 100) { printf(message); } } warning C6286: (<non-zero constant> || <expression>) is always a non-zero constant. <expression> is never evaluated and might have side effects
  • 17. void TraceInformation(char *message, int &totalMessages) { // Only print messages if there are // more than 100 of them or the trace // settings are set to verbose totalMessages++; if (TRACE_LEVEL > 3 || totalMessages > 100) { printf(message); } }
  • 18. public FldBrwserDlgExForm(): SomeSystem.SomeWindows.SomeForms.SomeForm { CA1704 : Microsoft.Naming : Correct the spelling of new in member name 'rtb.AcpectsTabs‘ this.opnFilDlg = 'Acpects' opnFilDlg(); CA1704 : Microsoft.Naming : Correct the spelling of 'Brwser' in new fldrBrwsrDlg1(); this.fldrBrwsrDlg1 = type name 'FldBrwserDlgExForm'. this.rtb = new rtb(); CA1704 : Correct the spelling of 'Brwsr' in type name 'fldrBrwsrDlg1'. this.opnFilDlg.DfltExt = "rtf"; this.desc = "Select the dir you want to use as CA1704 : Correct the spelling of 'Btn' in member name 'fldrBrwsrDlg1.ShowNewFldrBtn’ default"; CA1704 : Correct the spelling of 'desc' in member name 'FldBrwserDlgExForm.desc' this.fldrBrwsrDlg1.ShowNewFldrBtn = false; this.rtb.AcpectsTabs = true; CA1704 : Correct the spelling of 'Dflt' in member name 'opnFilDlg.DfltExt' } CA1704 : Correct the spelling of 'Dlg' in type name 'FldBrwserDlgExForm'. CA1704 : Correct the spelling of 'Fil' in type name 'opnFilDlg'. CA1704 : Correct the spelling of 'Fld' in type name 'FldBrwserDlgExForm'. CA1704 : Microsoft.Naming : Correct the spelling of 'opn' in type name 'opnFilDlg'. CA1704 : Microsoft.Naming : Correct the spelling of 'rtb' in type name 'rtb'.
  • 19. public class FolderBrowserDialogExampleForm : System.Windows.Forms.Form { // Constructor. public FolderBrowserDialogExampleForm() { this.openFileDialog1 = new OpenFileDialog(); this.folderBrowserDialog1 = new FolderBrowserDialog(); this.richTextBox1 = new RichTextBox(); this.openFileDialog1.DefaultExt = "rtf"; // Set the help text description this.folderBrowserDialog1.Description = "Select the directory that you want to use as the default."; // Do not allow the user to create new files this.folderBrowserDialog1.ShowNewFolderButton = false; this.richTextBox1.AcceptsTab = true; } }
  • 20. demo
  • 22. Maintainability Cyclomatic Class Coupling Index Complexity Green > 60 < 10 < 20 Yellow 40 - 60 10 - 15 Red < 40 > 15 > 20
  • 24. demo
  • 26. demo

Editor's Notes

  • #2: With Visual Studio 2012 and Team Foundation Server 2012 there have been a lot of improvements to make developer collaboration even easier. We cover integrated code review, the new “My Work” experience for managing your active tasks, and once you’re “in the zone” we help you stay focused on the task at hand, no matter how much you’re randomized. We walk the full gamut of collaboration improvements, from the newly revamped Team Explorer, to the version control and build improvements. Want to work offline seamlessly? Wish merging happened less frequently and was simpler when it did? How about find work items faster? We talk about all this and more.