SlideShare a Scribd company logo
1 of 6
Clean Code
Prepared By : Smita Prasad
Points to remember
• Make it easy to read,
• Make the surrounding code clean,
• Change one variable name for the better,
• Break up one function that’s a little too large,
• Eliminate one small bit of duplication,
• Clean up one composite if statement.
• Use meaningful names
• Distinguish names in such a way that the reader knows what the differences offer
• Use Pronounceable Names
Functions
• Functions should be small. They should do one thing. They should do it well. They
should do it only.
• We want to read the code like a top-down narrative.
• Use descriptive names for functions.
• Switch statements should be buried deep in a low-level class and should never be
repeated.
• Use Descriptive names for the functions. The smaller and more focused a function is,
the easier it is to choose a descriptive name.
• For a function three or more arguments should be avoided. Ideal is zero arguments.
• Flag arguments are ugly.
• When a function needs more than two or three arguments then wrap the arguments
into a class of their own.
• Functions should either do something or answer something, but not both.
• Extract the bodies of the try and catch blocks out into functions of their own.
• Duplication may be the root of all evil in software. Many principles and practices have
been created for the purpose of controlling or eliminating it.
Comments
• Adding comments is not good as it shows your failure in writing an expressive
code.
• Either spend your time writing the comments that explain the mess you’ve made
or spend it cleaning that mess.
• Don’t Use a Comment When You Can Use a Function or a Variable
• Comments are good only if they
– Meant for legal documentation
– Provide Informative value for a complex regular expression or formula
– Explain the intent or business requirement
– Clarify the third party library or API usage
– Warn about consequences
– Denote TODO tasks
– Amplify the importance of something
Formatting
• Code formatting is about communication, and communication is the professional
developer’s first order of business
• A team of developers should agree upon a single formatting style, and then every
member of that team should use that style.
• The reader needs to be able to trust that the formatting gestures he or she has
seen in one source file will mean the same thing in others.
• Vertical Size: Small files are usually easier to understand than large files are
• Source file should appear like a newspaper article.
• Horizontal Size: Strive to keep our lines short
Thanks

More Related Content

What's hot

Most Asked Python Interview Questions
Most Asked Python Interview QuestionsMost Asked Python Interview Questions
Most Asked Python Interview QuestionsShubham Shrimant
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python ProgrammingKAUSHAL KUMAR JHA
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data typeswati kushwaha
 
Numeric Data types in Python
Numeric Data types in PythonNumeric Data types in Python
Numeric Data types in Pythonjyostna bodapati
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPTShivam Gupta
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To PythonVanessa Rene
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slidesrfojdar
 
What is Python? An overview of Python for science.
What is Python? An overview of Python for science.What is Python? An overview of Python for science.
What is Python? An overview of Python for science.Nicholas Pringle
 

What's hot (15)

Python programming
Python programmingPython programming
Python programming
 
Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11Data handling CBSE PYTHON CLASS 11
Data handling CBSE PYTHON CLASS 11
 
Most Asked Python Interview Questions
Most Asked Python Interview QuestionsMost Asked Python Interview Questions
Most Asked Python Interview Questions
 
Summer Training Project On Python Programming
Summer Training Project On Python ProgrammingSummer Training Project On Python Programming
Summer Training Project On Python Programming
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Programming
ProgrammingProgramming
Programming
 
Numeric Data types in Python
Numeric Data types in PythonNumeric Data types in Python
Numeric Data types in Python
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Python Seminar PPT
Python Seminar PPTPython Seminar PPT
Python Seminar PPT
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
 
What is Python? An overview of Python for science.
What is Python? An overview of Python for science.What is Python? An overview of Python for science.
What is Python? An overview of Python for science.
 

Viewers also liked

PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An IntroductionSmita Prasad
 
POSTGRE DATABASE- recommend
POSTGRE DATABASE- recommendPOSTGRE DATABASE- recommend
POSTGRE DATABASE- recommendJacek Fleszar
 
Business Continuity Considerations for a More Reliable Postgres Environment
Business Continuity Considerations for a More Reliable Postgres EnvironmentBusiness Continuity Considerations for a More Reliable Postgres Environment
Business Continuity Considerations for a More Reliable Postgres EnvironmentEDB
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningQuick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningRon Morgan
 
Reducing the Risks of Migrating Off Oracle
Reducing the Risks of Migrating Off OracleReducing the Risks of Migrating Off Oracle
Reducing the Risks of Migrating Off OracleEDB
 
Openday - PostgreSQL: primi passi con Json/Jsonb
Openday - PostgreSQL: primi passi con Json/Jsonb Openday - PostgreSQL: primi passi con Json/Jsonb
Openday - PostgreSQL: primi passi con Json/Jsonb PgTraining
 
Minimize Headaches with Your Postgres Deployment
Minimize Headaches with Your Postgres DeploymentMinimize Headaches with Your Postgres Deployment
Minimize Headaches with Your Postgres DeploymentEDB
 
Learn Apache Shiro
Learn Apache ShiroLearn Apache Shiro
Learn Apache ShiroSmita Prasad
 
PostgreSQL: Prima configurazione
PostgreSQL: Prima configurazionePostgreSQL: Prima configurazione
PostgreSQL: Prima configurazioneEnrico Pirozzi
 
Spring @Transactional Explained
Spring @Transactional ExplainedSpring @Transactional Explained
Spring @Transactional ExplainedSmita Prasad
 
Hello World with EDB Postgres
Hello World with EDB PostgresHello World with EDB Postgres
Hello World with EDB PostgresEDB
 
Drive DBMS Transformation with EDB Postgres
Drive DBMS Transformation with EDB PostgresDrive DBMS Transformation with EDB Postgres
Drive DBMS Transformation with EDB PostgresEDB
 
Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Ali MasudianPour
 
Postgres Point-in-Time Recovery
Postgres Point-in-Time RecoveryPostgres Point-in-Time Recovery
Postgres Point-in-Time RecoveryEDB
 

Viewers also liked (20)

PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An Introduction
 
Intro to React.js
Intro to React.jsIntro to React.js
Intro to React.js
 
An Introduction to Postgresql
An Introduction to PostgresqlAn Introduction to Postgresql
An Introduction to Postgresql
 
POSTGRE DATABASE- recommend
POSTGRE DATABASE- recommendPOSTGRE DATABASE- recommend
POSTGRE DATABASE- recommend
 
Messa in rete
Messa in reteMessa in rete
Messa in rete
 
Apcamp
ApcampApcamp
Apcamp
 
Maven advanced
Maven advancedMaven advanced
Maven advanced
 
Business Continuity Considerations for a More Reliable Postgres Environment
Business Continuity Considerations for a More Reliable Postgres EnvironmentBusiness Continuity Considerations for a More Reliable Postgres Environment
Business Continuity Considerations for a More Reliable Postgres Environment
 
Quick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance TuningQuick guide to PostgreSQL Performance Tuning
Quick guide to PostgreSQL Performance Tuning
 
Reducing the Risks of Migrating Off Oracle
Reducing the Risks of Migrating Off OracleReducing the Risks of Migrating Off Oracle
Reducing the Risks of Migrating Off Oracle
 
Openday - PostgreSQL: primi passi con Json/Jsonb
Openday - PostgreSQL: primi passi con Json/Jsonb Openday - PostgreSQL: primi passi con Json/Jsonb
Openday - PostgreSQL: primi passi con Json/Jsonb
 
Minimize Headaches with Your Postgres Deployment
Minimize Headaches with Your Postgres DeploymentMinimize Headaches with Your Postgres Deployment
Minimize Headaches with Your Postgres Deployment
 
Learn Apache Shiro
Learn Apache ShiroLearn Apache Shiro
Learn Apache Shiro
 
PostgreSQL: Prima configurazione
PostgreSQL: Prima configurazionePostgreSQL: Prima configurazione
PostgreSQL: Prima configurazione
 
Spring @Transactional Explained
Spring @Transactional ExplainedSpring @Transactional Explained
Spring @Transactional Explained
 
Hello World with EDB Postgres
Hello World with EDB PostgresHello World with EDB Postgres
Hello World with EDB Postgres
 
Drive DBMS Transformation with EDB Postgres
Drive DBMS Transformation with EDB PostgresDrive DBMS Transformation with EDB Postgres
Drive DBMS Transformation with EDB Postgres
 
Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Rapid postgresql learning, part 1
Rapid postgresql learning, part 1
 
Postgres Point-in-Time Recovery
Postgres Point-in-Time RecoveryPostgres Point-in-Time Recovery
Postgres Point-in-Time Recovery
 
Shraddha Sharma
Shraddha SharmaShraddha Sharma
Shraddha Sharma
 

Similar to Clean code

Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)Shirish Bari
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programmingJuggernaut Liu
 
c-coding-standards-and-best-programming-practices.ppt
c-coding-standards-and-best-programming-practices.pptc-coding-standards-and-best-programming-practices.ppt
c-coding-standards-and-best-programming-practices.pptVinayakHospet1
 
CPP16 - Object Design
CPP16 - Object DesignCPP16 - Object Design
CPP16 - Object DesignMichael Heron
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytechyannick grenzinger
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptxSKUP1
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxSKUP ACADEMY
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxSKUP ACADEMY
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptxLECO9
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentationBhavin Gandhi
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesDr. Syed Hassan Amin
 
Clean code - DSC DYPCOE
Clean code - DSC DYPCOEClean code - DSC DYPCOE
Clean code - DSC DYPCOEPatil Shreyas
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane2
 

Similar to Clean code (20)

Clean code
Clean codeClean code
Clean code
 
Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
c-coding-standards-and-best-programming-practices.ppt
c-coding-standards-and-best-programming-practices.pptc-coding-standards-and-best-programming-practices.ppt
c-coding-standards-and-best-programming-practices.ppt
 
CPP16 - Object Design
CPP16 - Object DesignCPP16 - Object Design
CPP16 - Object Design
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptx
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptx
 
C STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptxC STANDARDS (C17) (1).pptx
C STANDARDS (C17) (1).pptx
 
C STANDARDS (C17).pptx
C STANDARDS (C17).pptxC STANDARDS (C17).pptx
C STANDARDS (C17).pptx
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
Clean Code
Clean CodeClean Code
Clean Code
 
208-09-writing.ppt
208-09-writing.ppt208-09-writing.ppt
208-09-writing.ppt
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
 
Clean code - DSC DYPCOE
Clean code - DSC DYPCOEClean code - DSC DYPCOE
Clean code - DSC DYPCOE
 
Lecture 24
Lecture 24Lecture 24
Lecture 24
 
Software development fundamentals
Software development fundamentalsSoftware development fundamentals
Software development fundamentals
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 

Recently uploaded

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Recently uploaded (20)

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Clean code

  • 1. Clean Code Prepared By : Smita Prasad
  • 2. Points to remember • Make it easy to read, • Make the surrounding code clean, • Change one variable name for the better, • Break up one function that’s a little too large, • Eliminate one small bit of duplication, • Clean up one composite if statement. • Use meaningful names • Distinguish names in such a way that the reader knows what the differences offer • Use Pronounceable Names
  • 3. Functions • Functions should be small. They should do one thing. They should do it well. They should do it only. • We want to read the code like a top-down narrative. • Use descriptive names for functions. • Switch statements should be buried deep in a low-level class and should never be repeated. • Use Descriptive names for the functions. The smaller and more focused a function is, the easier it is to choose a descriptive name. • For a function three or more arguments should be avoided. Ideal is zero arguments. • Flag arguments are ugly. • When a function needs more than two or three arguments then wrap the arguments into a class of their own. • Functions should either do something or answer something, but not both. • Extract the bodies of the try and catch blocks out into functions of their own. • Duplication may be the root of all evil in software. Many principles and practices have been created for the purpose of controlling or eliminating it.
  • 4. Comments • Adding comments is not good as it shows your failure in writing an expressive code. • Either spend your time writing the comments that explain the mess you’ve made or spend it cleaning that mess. • Don’t Use a Comment When You Can Use a Function or a Variable • Comments are good only if they – Meant for legal documentation – Provide Informative value for a complex regular expression or formula – Explain the intent or business requirement – Clarify the third party library or API usage – Warn about consequences – Denote TODO tasks – Amplify the importance of something
  • 5. Formatting • Code formatting is about communication, and communication is the professional developer’s first order of business • A team of developers should agree upon a single formatting style, and then every member of that team should use that style. • The reader needs to be able to trust that the formatting gestures he or she has seen in one source file will mean the same thing in others. • Vertical Size: Small files are usually easier to understand than large files are • Source file should appear like a newspaper article. • Horizontal Size: Strive to keep our lines short