SlideShare uma empresa Scribd logo
1 de 29
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)));
    }
}
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
Maintainability   Cyclomatic   Class Coupling
         Index             Complexity

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

Mais conteúdo relacionado

Mais procurados

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 Beneluxyohanbeschi
 
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 aboutDror Helper
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent codeDror Helper
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerDarwin Durand
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven PractisesRobert MacLean
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesDavid Rodenas
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Kim 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 TestsTomek 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.17LogeekNightUkraine
 
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 IIReem Alattas
 

Mais procurados (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
 
Spock framework
Spock frameworkSpock framework
Spock framework
 
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
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
Jason parsing
Jason parsingJason parsing
Jason parsing
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
Unit testing patterns for concurrent code
Unit testing patterns for concurrent codeUnit testing patterns for concurrent code
Unit testing patterns for concurrent code
 
Rxjs ngvikings
Rxjs ngvikingsRxjs ngvikings
Rxjs ngvikings
 
Visual Studio.Net - Sql Server
Visual Studio.Net - Sql ServerVisual Studio.Net - Sql Server
Visual Studio.Net - Sql Server
 
JavaScript Proven Practises
JavaScript Proven PractisesJavaScript Proven Practises
JavaScript Proven Practises
 
ES3-2020-07 Testing techniques
ES3-2020-07 Testing techniquesES3-2020-07 Testing techniques
ES3-2020-07 Testing techniques
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
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)
 
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
 
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
 
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
 
JavaScript Control Statements II
JavaScript Control Statements IIJavaScript Control Statements II
JavaScript Control Statements II
 
Codeofdatabase
CodeofdatabaseCodeofdatabase
Codeofdatabase
 

Destaque

Kina Affarer Nr 19 07
Kina Affarer Nr 19 07Kina Affarer Nr 19 07
Kina Affarer Nr 19 07bjorn_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 2011Technopreneurs Association of Malaysia
 
Career Planning - Job Application
Career Planning - Job ApplicationCareer Planning - Job Application
Career Planning - Job ApplicationDr. 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.11LM9
 
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 optimisationaf83media
 
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
 

Destaque (20)

Kina Affarer Nr 19 07
Kina Affarer Nr 19 07Kina Affarer Nr 19 07
Kina Affarer Nr 19 07
 
Bgt4
Bgt4Bgt4
Bgt4
 
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
 
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
 
My Personality Development
My Personality DevelopmentMy Personality Development
My Personality Development
 
Career Planning - Job Application
Career Planning - Job ApplicationCareer Planning - Job Application
Career Planning - Job Application
 
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"
 
INVESTOR INFORMATION SUMMARY
INVESTOR INFORMATION SUMMARYINVESTOR INFORMATION SUMMARY
INVESTOR INFORMATION SUMMARY
 
Dr. s.n.-khan (1)
Dr. s.n.-khan (1)Dr. s.n.-khan (1)
Dr. s.n.-khan (1)
 
Hadoop基线选定
Hadoop基线选定Hadoop基线选定
Hadoop基线选定
 
How to code
How to codeHow to code
How to code
 
투이컨설팅 제34회 Y세미나 : 설문결과
투이컨설팅 제34회 Y세미나 : 설문결과투이컨설팅 제34회 Y세미나 : 설문결과
투이컨설팅 제34회 Y세미나 : 설문결과
 
Ambush marketing
Ambush marketingAmbush marketing
Ambush marketing
 
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
 
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...
 
Hdfs
HdfsHdfs
Hdfs
 
Music : your social media optimisation
Music : your social media optimisationMusic : your social media optimisation
Music : your social media optimisation
 
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)
 
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
 
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
 

Semelhante a Ensure code quality with vs2012

Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsPVS-Studio
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayNatasha Murashev
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the mastersAra Pehlivanian
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimizedWoody Pewitt
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun 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 fundamentalsHCMUTE
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry 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 .pdfarihantmum
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4Abed Bukhari
 

Semelhante a 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
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
 
Expert JavaScript tricks of the masters
Expert JavaScript  tricks of the mastersExpert JavaScript  tricks of the masters
Expert JavaScript tricks of the masters
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
Anti patterns
Anti patternsAnti patterns
Anti patterns
 
Clean code
Clean codeClean code
Clean code
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
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 / ...
 
Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
Lambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter LawreyLambdas puzzler - Peter Lawrey
Lambdas puzzler - Peter Lawrey
 
Exception
ExceptionException
Exception
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
SOLID Java Code
SOLID Java CodeSOLID Java Code
SOLID Java Code
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
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
 
Whats new in_csharp4
Whats new in_csharp4Whats new in_csharp4
Whats new in_csharp4
 

Último

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Ensure code quality with vs2012

  • 1.
  • 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))); } }
  • 11.
  • 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
  • 21.
  • 22. Maintainability Cyclomatic Class Coupling Index Complexity Green > 60 < 10 < 20 Yellow 40 - 60 10 - 15 Red < 40 > 15 > 20
  • 23.
  • 24. demo
  • 25.
  • 26. demo

Notas do Editor

  1. 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.