SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Coding standards
Coding standardsCoding standards
Coding standardsMimoh Ojha
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jestpksjce
 
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 ProcessDr. Syed Hassan Amin
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelinesAnkur Goyal
 
Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)Carlos Mafla
 
SonarQube: Continuous Code Inspection
SonarQube: Continuous Code InspectionSonarQube: Continuous Code Inspection
SonarQube: Continuous Code InspectionMichael Jesse
 
C# conventions & good practices
C# conventions & good practicesC# conventions & good practices
C# conventions & good practicesTan Tran
 
Java Code Review Checklist
Java Code Review ChecklistJava Code Review Checklist
Java Code Review ChecklistMahesh Chopker
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-conceptsmedsherb
 
Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#Asim Rais Siddiqui
 

Was ist angesagt? (20)

Coding standards
Coding standardsCoding standards
Coding standards
 
Code Quality
Code QualityCode Quality
Code Quality
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Automation testing
Automation testingAutomation testing
Automation testing
 
Code coverage
Code coverageCode coverage
Code coverage
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
Introduction to jest
Introduction to jestIntroduction to jest
Introduction to jest
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
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
 
Angularjs PPT
Angularjs PPTAngularjs PPT
Angularjs PPT
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)Hook me UP ( React Hooks Introduction)
Hook me UP ( React Hooks Introduction)
 
SonarQube
SonarQubeSonarQube
SonarQube
 
SonarQube: Continuous Code Inspection
SonarQube: Continuous Code InspectionSonarQube: Continuous Code Inspection
SonarQube: Continuous Code Inspection
 
SonarQube Overview
SonarQube OverviewSonarQube Overview
SonarQube Overview
 
C# conventions & good practices
C# conventions & good practicesC# conventions & good practices
C# conventions & good practices
 
Java Code Review Checklist
Java Code Review ChecklistJava Code Review Checklist
Java Code Review Checklist
 
Basic software-testing-concepts
Basic software-testing-conceptsBasic software-testing-concepts
Basic software-testing-concepts
 
Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#Coding Standards & Best Practices for iOS/C#
Coding Standards & Best Practices for iOS/C#
 

Andere mochten auch

Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controlsGuddu gupta
 
Validation controls ppt
Validation controls pptValidation controls ppt
Validation controls pptIblesoft
 
Validation controls in asp
Validation controls in aspValidation controls in asp
Validation controls in aspShishir Jain
 
Code Review
Code ReviewCode Review
Code Reviewrantav
 
LAYERS asp.net ppt
LAYERS asp.net pptLAYERS asp.net ppt
LAYERS asp.net pptIMEI
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software EngineeringAbhay Vijay
 

Andere mochten auch (8)

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
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
Coding and testing in Software Engineering
Coding and testing in Software EngineeringCoding and testing in Software Engineering
Coding and testing in Software Engineering
 

Ähnlich wie Code review

Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#Svetlin Nakov
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddSrinivasa GV
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
21. High-Quality Programming Code
21. High-Quality Programming Code21. High-Quality Programming Code
21. High-Quality Programming CodeIntro C# Book
 
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 developmentMitosis Technology
 
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 CodeRock Interview
 
Codingstandards matiar
Codingstandards matiarCodingstandards matiar
Codingstandards matiarMatiar Rahman
 
The Testing Planet Issue 2
The Testing Planet Issue 2The Testing Planet Issue 2
The Testing Planet Issue 2Rosie 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
 
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 2019Paulo Clavijo
 
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 WorldDavid McCarter
 
Introduction to automated quality assurance
Introduction to automated quality assuranceIntroduction to automated quality assurance
Introduction to automated quality assurancePhilip Johnson
 
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 WorldDavid McCarter
 

Ähnlich wie 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
 
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
 
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
 

Mehr von Abhishek Sur

Azure servicefabric
Azure servicefabricAzure servicefabric
Azure servicefabricAbhishek Sur
 
Building a bot with an intent
Building a bot with an intentBuilding a bot with an intent
Building a bot with an intentAbhishek Sur
 
C# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesC# 7.0 Hacks and Features
C# 7.0 Hacks and FeaturesAbhishek Sur
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Stream Analytics Service in Azure
Stream Analytics Service in AzureStream Analytics Service in Azure
Stream Analytics Service in AzureAbhishek Sur
 
Designing azure compute and storage infrastructure
Designing azure compute and storage infrastructureDesigning azure compute and storage infrastructure
Designing azure compute and storage infrastructureAbhishek Sur
 
Working with Azure Resource Manager Templates
Working with Azure Resource Manager TemplatesWorking with Azure Resource Manager Templates
Working with Azure Resource Manager TemplatesAbhishek Sur
 
F12 debugging in Ms edge
F12 debugging in Ms edgeF12 debugging in Ms edge
F12 debugging in Ms edgeAbhishek Sur
 
Mobile Services for Windows Azure
Mobile Services for Windows AzureMobile Services for Windows Azure
Mobile Services for Windows AzureAbhishek Sur
 
Service bus to build Bridges
Service bus to build BridgesService bus to build Bridges
Service bus to build BridgesAbhishek Sur
 
Windows azure pack overview
Windows azure pack overviewWindows azure pack overview
Windows azure pack overviewAbhishek Sur
 
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 overviewAbhishek Sur
 
Di api di server b1 ws
Di api di server b1 wsDi api di server b1 ws
Di api di server b1 wsAbhishek Sur
 
Integrating cortana with wp8 app
Integrating cortana with wp8 appIntegrating cortana with wp8 app
Integrating cortana with wp8 appAbhishek Sur
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its featuresAbhishek Sur
 
SQL Server2012 Enhancements
SQL Server2012 EnhancementsSQL Server2012 Enhancements
SQL Server2012 EnhancementsAbhishek Sur
 
Dev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 EnhancementsDev days Visual Studio 2012 Enhancements
Dev days Visual Studio 2012 EnhancementsAbhishek Sur
 
Hidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsHidden Facts of .NET Language Gems
Hidden Facts of .NET Language GemsAbhishek Sur
 
ASP.NET 4.5 webforms
ASP.NET 4.5 webformsASP.NET 4.5 webforms
ASP.NET 4.5 webformsAbhishek Sur
 

Mehr von 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
 

Kürzlich hochgeladen

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 

Kürzlich hochgeladen (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.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)
 

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.