SlideShare uma empresa Scribd logo
1 de 19
“Think Twice. Code Once.”
What is Code Review?
“Code review is the systematic examination (often known as peer review) of
computer source code. It is intended to find and fix mistakes overlooked in
the initial development phase, improving both the overall quality of software
and the developers' skills.”
Going By Wikipedia :
It involves making pieces of source code
available for other developers to review, with
the intention of catching bugs and design
errors before the code becomes part of the
product.
Why do we need Code Review?
 Mistakes are caught before they become a part of the product
 Reviewing code by a second-eye points out the mistakes made at the time of
development, and correction at that time itself, reduces the bugs reported by the
testers and also the cost of testing.
 It ensures that codes follow standards defined by the organization's coding guidelines
even if the team is geographically distributed.
 Repetitive code blocks can be caught during a code review process and refactoring can
be done based on that.
 Code reviews can often find and remove common vulnerabilities such as format string
exploits, race conditions, memory leaks and buffer overflows, thereby improving
software security.
 It acts as a knowledge sharing platform by fostering greater communication and
providing invaluable educational context to junior developers.
Traditional Code Reviews
The idea of a formal, systematic code review
generally consisted of a bunch of people sitting
together around a table in a stuffy room, poring over
dot-matrix print-outs of computer code together, red
pens in hand, until they were bleary-eyed and brain-
dead.
The Code Review Process
What to check in a Code?
Flaws or potential
flaws
Consistency with the
overall program design
The quality
of comments.
Adherence to coding
standards.
Code Review Checklist
Naming Of Variables :
 Variable Names should follow Camel Casing.
 Variable Names should be meaningful and complete. Abbreviations should be
avoided.
 Do not use underscores (_) for local variable names.
 All Global variables in a class should be prefixed with underscore (_) so that they
can be identified from other local variables.
Bad : xx, xyz, a, cusordhis
Good : customerOrderHistory
Bad : amt, prc
Good : amount, price
Bad : customerorderhistory
Good : customerOrderHistory
Bad : globalCustomerName
Good : _customerName
Naming Of Methods :
 Method Names should follow Pascal Casing (Title Case).
 Method Name should be meaningful and complete. Abbreviations should be avoided.
 Method name should denote what it does.
 Async method should have suffix Async.
Bad : getrequiredfields
Good : GetRequiredFields
Bad : getlic, retdt
Good : GetLicense, ReturnDataTable
e.g. GetClientLicenseKey, ExecuteDeleteQuery
Bad : asyGetStock
Good : GetStockAsync
Naming Of Classes :
•Class Names should follow the Pascal Casing.
•Class Names should be meaningful and complete. Abbreviations should be avoided.
•Classes should be grouped and created in folders according to function.
•Classes should only expose methods and members which are required to be
accessed from outside the class
Bad : stockitem
Good : StockItem
Bad : Lic, tlydtimport
Good : Licensing, TallyDataImport
 Interfaces should start with I.
 Constants should be in all CAPS.
 Namespace, Folders should be in Pascal casing.
Bad : InterfaceStock
Good : IStock
Bad : secretKey
Good : SECRET_KEY
e.g. namespace AppResources
Commenting :
 All public / internal methods should have comments providing details of the
purpose of the function. Use XML comments ("///").
 Regions are used for long code blocks.
 Region names are meaningful.
 Any bug fix or code change should have Bug ID, Developer Initials, Date and short
comment.
/// <summary>
/// This class performs an important function.
/// </summary>
public class MyClass{}
#region MyClass definition
public class MyClass
{
static void Main()
{
}
}
#endregion
//ID:231 RK 02.03.2015 Changed the logic to take care of long item names
Coding Practices :
 Long functions / code block should be split into smaller functions.
Testing or Debugging of a code that does a lot of things is difficult. Write each
function so that it does one thing and only one thing.
 Hardcoded values should be defined in constant or config.
public static class ConstantVariables
{
public const string ConstantVariable1 = "my string";
}
use:
this.Text = ConstantVariables.ConstantVariable1;
Example using constant values:
•Add a reference to System.Configuration
•Add an "Application Configuration File" to your project
•Add a configuration key to the configuration file like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="myConfiguration" value="TestValue"/>
</appSettings>
</configuration>
•Within the code you can refer to the config file by using:
string configValue = System.Configuration.ConfigurationManager.AppSettings["myConfiguration"];
Example using config file:
Error Messages :
 Error messages should be defined in a central class.
 Error message should tell the user of the problem and the way to solve the
error or else it should ask the user to contact support / system administrator.
Incorrect :
• "Error in Application“
• "There is an error"
Correct :
• "Failed to update database. Please make sure the login id and
password are correct."
 Try catch is used for exception handling and not for flow control.
 Blank catch block is not used.
 Large try catch blocks should be split into smaller ones.
Error Control :
try {
myLabel.Text = school.SchoolName;
}
catch {
myPanel.Visible = false;
}
Bad Practice :
if (school != null) {
myLabel.Text = school.SchoolName;
}
else {
myPanel.Visible = false;
}
Good Practice :
Others :
 Assembly version is set according to version policy in Support Portal.
 Unit tests have been defined for the functions and methods.
 You can also add any specific comments or reviews.
 The event handler should not contain the code to perform the
required action. Rather call another method from the event handler.
Problems with Code Review
NO NEED TO DOUBLE
CHECK THIS CHANGE LIST,
IF SOME PROBLEM
REMAINS, THE REVIEWER
WILL CATCH THEM.
NO NEED TO LOOK AT THIS
CHANGE LIST TOO
CLOSELY, I’M SURE THE
AUTHOR KNOWS WHAT HE
IS DOING.
Code review
Code review

Mais conteúdo relacionado

Mais procurados

Sonarqube
SonarqubeSonarqube
Sonarqube
Kalkey
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
medsherb
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
Raghu Kiran
 

Mais procurados (20)

Sonarqube
SonarqubeSonarqube
Sonarqube
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Manual testing
Manual testingManual testing
Manual testing
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testing
 
Testing
TestingTesting
Testing
 
Manual testing concepts course 1
Manual testing concepts course 1Manual testing concepts course 1
Manual testing concepts course 1
 
Bug reporting and tracking
Bug reporting and trackingBug reporting and tracking
Bug reporting and tracking
 
SOFTWARE TESTING
SOFTWARE TESTINGSOFTWARE TESTING
SOFTWARE TESTING
 
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng NghĩaTech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
Tech Talk #5 : Code Analysis SonarQube - Lương Trọng Nghĩa
 
Coding standard and coding guideline
Coding standard and coding guidelineCoding standard and coding guideline
Coding standard and coding guideline
 
Documentation in the agile software development process
Documentation in the agile software development processDocumentation in the agile software development process
Documentation in the agile software development process
 
Software testing ppt
Software testing pptSoftware testing ppt
Software testing ppt
 
The story of SonarQube told to a DevOps Engineer
The story of SonarQube told to a DevOps EngineerThe story of SonarQube told to a DevOps Engineer
The story of SonarQube told to a DevOps Engineer
 
Software Quality Assurance
Software Quality AssuranceSoftware Quality Assurance
Software Quality Assurance
 
SonarQube: Continuous Code Inspection
SonarQube: Continuous Code InspectionSonarQube: Continuous Code Inspection
SonarQube: Continuous Code Inspection
 
Code Refactoring
Code RefactoringCode Refactoring
Code Refactoring
 
How to report bugs
How to report bugsHow to report bugs
How to report bugs
 
Types of testing
Types of testingTypes of testing
Types of testing
 
SonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code QualitySonarQube - The leading platform for Continuous Code Quality
SonarQube - The leading platform for Continuous Code Quality
 

Destaque (7)

Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
Validation controls ppt
Validation controls pptValidation controls ppt
Validation controls ppt
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in asp
 
Code Review
Code ReviewCode Review
Code Review
 
LAYERS asp.net ppt
LAYERS asp.net pptLAYERS asp.net ppt
LAYERS asp.net ppt
 
Software documentation
Software documentationSoftware documentation
Software documentation
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software Engineering
 

Semelhante a Code review

Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
Chandra Sekhar Saripaka
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tdd
Srinivasa GV
 
Code Review
Code ReviewCode Review
Code Review
Ravi Raj
 
Codingstandards matiar
Codingstandards matiarCodingstandards matiar
Codingstandards matiar
Matiar Rahman
 
The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2
Rosie Sherry
 
Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.
DrupalCampDN
 
Introduction to automated quality assurance
Introduction to automated quality assuranceIntroduction to automated quality assurance
Introduction to automated quality assurance
Philip Johnson
 

Semelhante a Code review (20)

Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Abcxyz
AbcxyzAbcxyz
Abcxyz
 
Ensuring code quality
Ensuring code qualityEnsuring code quality
Ensuring code quality
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tdd
 
Code Review
Code ReviewCode Review
Code Review
 
21. High-Quality Programming Code
21. High-Quality Programming Code21. High-Quality Programming Code
21. High-Quality Programming Code
 
How to do code review and use analysis tool in software development
How to do code review and use analysis tool in software developmentHow to do code review and use analysis tool in software development
How to do code review and use analysis tool in software development
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
Unit iv
Unit ivUnit iv
Unit iv
 
How To Tidy Up Your Test Code
How To Tidy Up Your Test CodeHow To Tidy Up Your Test Code
How To Tidy Up Your Test Code
 
Codingstandards matiar
Codingstandards matiarCodingstandards matiar
Codingstandards matiar
 
SE2_Lec 18_ Coding
SE2_Lec 18_ CodingSE2_Lec 18_ Coding
SE2_Lec 18_ Coding
 
SE2018_Lec 17_ Coding
SE2018_Lec 17_ CodingSE2018_Lec 17_ Coding
SE2018_Lec 17_ Coding
 
The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2
 
Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.Code Review Looking for a vulnerable code. Vlad Savitsky.
Code Review Looking for a vulnerable code. Vlad Savitsky.
 
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019Breaking Dependencies Legacy Code -  Cork Software Crafters - September 2019
Breaking Dependencies Legacy Code - Cork Software Crafters - September 2019
 
Back-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real WorldBack-2-Basics: .NET Coding Standards For The Real World
Back-2-Basics: .NET Coding Standards For The Real World
 
Introduction to automated quality assurance
Introduction to automated quality assuranceIntroduction to automated quality assurance
Introduction to automated quality assurance
 

Mais de Abhishek Sur

Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
Abhishek Sur
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
Abhishek Sur
 

Mais de Abhishek Sur (20)

Azure servicefabric
Azure servicefabricAzure servicefabric
Azure servicefabric
 
Building a bot with an intent
Building a bot with an intentBuilding a bot with an intent
Building a bot with an intent
 
C# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesC# 7.0 Hacks and Features
C# 7.0 Hacks and Features
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Stream Analytics Service in Azure
Stream Analytics Service in AzureStream Analytics Service in Azure
Stream Analytics Service in Azure
 
Designing azure compute and storage infrastructure
Designing azure compute and storage infrastructureDesigning azure compute and storage infrastructure
Designing azure compute and storage infrastructure
 
Working with Azure Resource Manager Templates
Working with Azure Resource Manager TemplatesWorking with Azure Resource Manager Templates
Working with Azure Resource Manager Templates
 
F12 debugging in Ms edge
F12 debugging in Ms edgeF12 debugging in Ms edge
F12 debugging in Ms edge
 
Mobile Services for Windows Azure
Mobile Services for Windows AzureMobile Services for Windows Azure
Mobile Services for Windows Azure
 
Service bus to build Bridges
Service bus to build BridgesService bus to build Bridges
Service bus to build Bridges
 
Windows azure pack overview
Windows azure pack overviewWindows azure pack overview
Windows azure pack overview
 
AMicrosoft azure hyper v recovery manager overview
AMicrosoft azure hyper v recovery manager overviewAMicrosoft azure hyper v recovery manager overview
AMicrosoft azure hyper v recovery manager overview
 
Di api di server b1 ws
Di api di server b1 wsDi api di server b1 ws
Di api di server b1 ws
 
Integrating cortana with wp8 app
Integrating cortana with wp8 appIntegrating cortana with wp8 app
Integrating cortana with wp8 app
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
 
SQL Server2012 Enhancements
SQL Server2012 EnhancementsSQL Server2012 Enhancements
SQL Server2012 Enhancements
 
Dev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 EnhancementsDev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 Enhancements
 
Hidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsHidden Facts of .NET Language Gems
Hidden Facts of .NET Language Gems
 
ASP.NET 4.5 webforms
ASP.NET 4.5 webformsASP.NET 4.5 webforms
ASP.NET 4.5 webforms
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Code review

  • 2. What is Code Review? “Code review is the systematic examination (often known as peer review) of computer source code. It is intended to find and fix mistakes overlooked in the initial development phase, improving both the overall quality of software and the developers' skills.” Going By Wikipedia : It involves making pieces of source code available for other developers to review, with the intention of catching bugs and design errors before the code becomes part of the product.
  • 3. Why do we need Code Review?  Mistakes are caught before they become a part of the product  Reviewing code by a second-eye points out the mistakes made at the time of development, and correction at that time itself, reduces the bugs reported by the testers and also the cost of testing.  It ensures that codes follow standards defined by the organization's coding guidelines even if the team is geographically distributed.  Repetitive code blocks can be caught during a code review process and refactoring can be done based on that.  Code reviews can often find and remove common vulnerabilities such as format string exploits, race conditions, memory leaks and buffer overflows, thereby improving software security.  It acts as a knowledge sharing platform by fostering greater communication and providing invaluable educational context to junior developers.
  • 4. Traditional Code Reviews The idea of a formal, systematic code review generally consisted of a bunch of people sitting together around a table in a stuffy room, poring over dot-matrix print-outs of computer code together, red pens in hand, until they were bleary-eyed and brain- dead.
  • 5. The Code Review Process
  • 6. What to check in a Code? Flaws or potential flaws Consistency with the overall program design The quality of comments. Adherence to coding standards.
  • 7. Code Review Checklist Naming Of Variables :  Variable Names should follow Camel Casing.  Variable Names should be meaningful and complete. Abbreviations should be avoided.  Do not use underscores (_) for local variable names.  All Global variables in a class should be prefixed with underscore (_) so that they can be identified from other local variables. Bad : xx, xyz, a, cusordhis Good : customerOrderHistory Bad : amt, prc Good : amount, price Bad : customerorderhistory Good : customerOrderHistory Bad : globalCustomerName Good : _customerName
  • 8. Naming Of Methods :  Method Names should follow Pascal Casing (Title Case).  Method Name should be meaningful and complete. Abbreviations should be avoided.  Method name should denote what it does.  Async method should have suffix Async. Bad : getrequiredfields Good : GetRequiredFields Bad : getlic, retdt Good : GetLicense, ReturnDataTable e.g. GetClientLicenseKey, ExecuteDeleteQuery Bad : asyGetStock Good : GetStockAsync
  • 9. Naming Of Classes : •Class Names should follow the Pascal Casing. •Class Names should be meaningful and complete. Abbreviations should be avoided. •Classes should be grouped and created in folders according to function. •Classes should only expose methods and members which are required to be accessed from outside the class Bad : stockitem Good : StockItem Bad : Lic, tlydtimport Good : Licensing, TallyDataImport
  • 10.  Interfaces should start with I.  Constants should be in all CAPS.  Namespace, Folders should be in Pascal casing. Bad : InterfaceStock Good : IStock Bad : secretKey Good : SECRET_KEY e.g. namespace AppResources
  • 11. Commenting :  All public / internal methods should have comments providing details of the purpose of the function. Use XML comments ("///").  Regions are used for long code blocks.  Region names are meaningful.  Any bug fix or code change should have Bug ID, Developer Initials, Date and short comment. /// <summary> /// This class performs an important function. /// </summary> public class MyClass{} #region MyClass definition public class MyClass { static void Main() { } } #endregion //ID:231 RK 02.03.2015 Changed the logic to take care of long item names
  • 12. Coding Practices :  Long functions / code block should be split into smaller functions. Testing or Debugging of a code that does a lot of things is difficult. Write each function so that it does one thing and only one thing.  Hardcoded values should be defined in constant or config. public static class ConstantVariables { public const string ConstantVariable1 = "my string"; } use: this.Text = ConstantVariables.ConstantVariable1; Example using constant values:
  • 13. •Add a reference to System.Configuration •Add an "Application Configuration File" to your project •Add a configuration key to the configuration file like: <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="myConfiguration" value="TestValue"/> </appSettings> </configuration> •Within the code you can refer to the config file by using: string configValue = System.Configuration.ConfigurationManager.AppSettings["myConfiguration"]; Example using config file:
  • 14. Error Messages :  Error messages should be defined in a central class.  Error message should tell the user of the problem and the way to solve the error or else it should ask the user to contact support / system administrator. Incorrect : • "Error in Application“ • "There is an error" Correct : • "Failed to update database. Please make sure the login id and password are correct."
  • 15.  Try catch is used for exception handling and not for flow control.  Blank catch block is not used.  Large try catch blocks should be split into smaller ones. Error Control : try { myLabel.Text = school.SchoolName; } catch { myPanel.Visible = false; } Bad Practice : if (school != null) { myLabel.Text = school.SchoolName; } else { myPanel.Visible = false; } Good Practice :
  • 16. Others :  Assembly version is set according to version policy in Support Portal.  Unit tests have been defined for the functions and methods.  You can also add any specific comments or reviews.  The event handler should not contain the code to perform the required action. Rather call another method from the event handler.
  • 17. Problems with Code Review NO NEED TO DOUBLE CHECK THIS CHANGE LIST, IF SOME PROBLEM REMAINS, THE REVIEWER WILL CATCH THEM. NO NEED TO LOOK AT THIS CHANGE LIST TOO CLOSELY, I’M SURE THE AUTHOR KNOWS WHAT HE IS DOING.