SlideShare a Scribd company logo
CODE STANDARDS &
BEST PRACTICES

Md. Ibrahim Rashid [ irashid.com ]
Good Code Vs. Bad Code
Good Code Vs. Bad Code
    “The best applications are coded properly”
    This sounds like an obvious statement, but by
    „properly‟, I mean that the code not only does its
    job well, but is also easy to add to, maintain and
    debug.
Ask Yourself?
   Is your code well organized and maintainable?
   Is you code well documented?
General Practices
   Naming Conventions
   Indentation
   Brace Style
   Commenting
   Code consistency
   Readability Vs. Compression
What should coding standards
provide?
   File, class, variable naming conventions
   Code formatting conventions
   Guidelines for consistency across the code
   Uniformity
Naming Conventions
   Class names are MixedCase
       [ ex. MyClass ]
   Method names are camelCase
       [ ex. myMethod() ]
   Constants are ALL_CAPS
       [ MY_CONSTANT ]
   Properties and variables are camelCase
       [ ex. myMethod() ]
   Non-public class members are _underscorePrefixed
       [Ex. _myPrivateVariable ]
Various Conventions

Class names        MyClass
Method names       my_function()          myFunction()        MyFunction
Constants          MY_CONSTANT
Properties and     my_variable            myVariable
variables
Non-public class   _my_private_variable   _myPrivateVariabl
members                                   e
Filenames          MyFile.php             myFile.php          my_file.php
Class Filenames    ClassMyFile.php        classMyFile.php     class_my_file.p
                                                              hp

        Case insensitive : MyFile.php and myfile.php are same in
        windows
Example
Scenario 1
Scenario 2
Scenario 3
Senerio 4(!BAD Don‟t MIX)
Indentation
PHP(Drupal)       Wordpress(PHP)   C(K&R
                                   standard)
Use an indent of 2 Use real         Tab = 4
spaces, with no    tabs and not    spaces
tabs               spaces,
Indentation
Indentation
 Always Make
Proper Indent.
Indentation
   Use of Real Tabs, 4 space as Tabs, only
    spaces is
    controversial.
   It‟s because same source code loaded into
    different editors with distinct setting will not
    look alike.
   Use lines less than 80 characters.
Indentation
   Brace Style
Indentation
   Brace Style
Indentation
   Use of Real Tabs, 4 space as Tabs, only
    spaces is
    controversial.
   It‟s because same source code loaded into
    different editors with distinct setting will not
    look alike.
   Use lines less than 80 characters.
Indentation
Commenting
   Always try to put comments on your code.
Commenting
Commenting
Commenting
Self documenting code
   Use of Long Method Name that reflects the
    purpose of the method.
   Still It needs to be commented.
Code Readability




       Always try to make readable code.
Readability Vs. Compression




                   YES!! I saved lots of bytes. Code is now compact.




There are lots of tools for making code compact. You don‟t have to write in
unreadable compact form.
Code consistency
   Let a project has 3 members.
   They watch this slide very carefully , and
    realized the importance of coding standard &
    best practices.
   Now, they are told to do the project perfectly.
   Each members uses his/her coding convention
    and submitted the project.
   What will be the output ?
Code consistency
   Always use same standard throughout a
    project.
   All members of a project must choose a fixed
    convention before starting a project.
Learn from Others
   Don’t invent your own standard. All of the
    issues have already been debated to death
    by many others.
   Use an established standard
    •  Minimize politics by choosing an external
      standard
     • Choose a standard compatible with the libraries
      you use
     • Use the standard as a requirement when
      outsourcing
   Stick to the standard you establish, don‟t mix
How To Write Unmaintainable
                             Code
                                  Ensure a job for life ;-)

   Read This Site Carefully with negating every
    concept.
   http://thc.org/root/phun/unmaintain.html
References
   http://wiki.mozilla.org/WebDev:FrontendCodeStandards
   http://na.isobar.com/standards/
   http://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming
    _Languages/C%2B%2B/Code/Style_Conventions
   http://en.wikipedia.org/wiki/Best_Coding_Practices
   http://codex.wordpress.org/WordPress_Coding_Standards
   http://drupal.org/coding-standards
   Java Code Conventions
   http://www.sitepoint.com/coding-standards/
   http://www.programming4scientists.com/2008/09/26/good-code-
    bad-code-an-example/
   http://thc.org/root/phun/unmaintain.html
Coding conventions
Coding conventions

More Related Content

What's hot

Coding standards
Coding standardsCoding standards
Coding standards
BishalAryal8
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoring
Eyob Lube
 
C# conventions & good practices
C# conventions & good practicesC# conventions & good practices
C# conventions & good practices
Tan Tran
 
Coding standard
Coding standardCoding standard
Coding standard
FAROOK Samath
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for javamaheshm1206
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
Geshan Manandhar
 
Clean code: meaningful Name
Clean code: meaningful NameClean code: meaningful Name
Clean code: meaningful Namenahid035
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
saber tabatabaee
 
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
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
Igor Crvenov
 
Clean Code
Clean CodeClean Code
Clean Code
Hendrik Ebel
 
Clean code
Clean codeClean code
Clean code
Mahmoud Zizo
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next Chapter
Victor Rentea
 
Clean Code Principles
Clean Code PrinciplesClean Code Principles
Clean Code Principles
YeurDreamin'
 
Clean code
Clean codeClean code
Clean code
Henrique Smoco
 
Clean code slide
Clean code slideClean code slide
Clean code slide
Anh Huan Miu
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
Vishwa Mohan
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constantsvinay arora
 
Introduction to c#
Introduction to c#Introduction to c#

What's hot (20)

Coding standards
Coding standardsCoding standards
Coding standards
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoring
 
C# conventions & good practices
C# conventions & good practicesC# conventions & good practices
C# conventions & good practices
 
Coding standard
Coding standardCoding standard
Coding standard
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
7 rules of simple and maintainable code
7 rules of simple and maintainable code7 rules of simple and maintainable code
7 rules of simple and maintainable code
 
Clean code: meaningful Name
Clean code: meaningful NameClean code: meaningful Name
Clean code: meaningful Name
 
clean code book summary - uncle bob - English version
clean code book summary - uncle bob - English versionclean code book summary - uncle bob - English version
clean code book summary - uncle bob - English version
 
Writing High Quality Code in C#
Writing High Quality Code in C#Writing High Quality Code in C#
Writing High Quality Code in C#
 
Refactoring Tips by Martin Fowler
Refactoring Tips by Martin FowlerRefactoring Tips by Martin Fowler
Refactoring Tips by Martin Fowler
 
Clean Code
Clean CodeClean Code
Clean Code
 
Clean code
Clean codeClean code
Clean code
 
Clean Code - The Next Chapter
Clean Code - The Next ChapterClean Code - The Next Chapter
Clean Code - The Next Chapter
 
Clean Code Principles
Clean Code PrinciplesClean Code Principles
Clean Code Principles
 
Clean code
Clean codeClean code
Clean code
 
Clean code slide
Clean code slideClean code slide
Clean code slide
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 

Viewers also liked

Three Laws of Trusted Data Sharing: (Building a Better Business Case for Dat...
Three Laws of Trusted Data Sharing:(Building a Better Business Case for Dat...Three Laws of Trusted Data Sharing:(Building a Better Business Case for Dat...
Three Laws of Trusted Data Sharing: (Building a Better Business Case for Dat...
CS, NcState
 
Codes and conventions of news programming
Codes and conventions of news programming Codes and conventions of news programming
Codes and conventions of news programming
joshutb
 
Why coding convention ?
Why coding convention ?Why coding convention ?
Why coding convention ?
Panji Gautama
 
적당한 스터디 발표자료 만들기
적당한 스터디 발표자료 만들기적당한 스터디 발표자료 만들기
적당한 스터디 발표자료 만들기
종빈 오
 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java Coding
Rahul Bhutkar
 
Drawing Standards & Conventions: Lecture 2
Drawing Standards & Conventions: Lecture 2Drawing Standards & Conventions: Lecture 2
Drawing Standards & Conventions: Lecture 2
Virtu Institute
 
MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016Andrew Banks
 
Codings Standards
Codings StandardsCodings Standards
Codings Standards
Philip Johnson
 
Android code convention
Android code conventionAndroid code convention
Android code convention
Siddiq Abu Bakkar
 
MISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the futureMISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the future
AdaCore
 
Misra C Software Development Standard
Misra C Software Development StandardMisra C Software Development Standard
Misra C Software Development Standard
Vittorio Giovara
 
Coding standards
Coding standardsCoding standards
Coding standards
Mimoh Ojha
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
manugoel2003
 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding conventionTam Thanh
 
Understand codes, conventions, styles and structures
Understand codes, conventions, styles and structuresUnderstand codes, conventions, styles and structures
Understand codes, conventions, styles and structuresmattwako
 
Learning styles
Learning stylesLearning styles
Learning styles
aghchay
 
Codes & Conventions
Codes & ConventionsCodes & Conventions
Codes & Conventions954869
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
kamal kotecha
 
Basics of Functional Neuroanatomy
Basics of Functional NeuroanatomyBasics of Functional Neuroanatomy
Basics of Functional Neuroanatomy
Vivek Misra
 

Viewers also liked (20)

Three Laws of Trusted Data Sharing: (Building a Better Business Case for Dat...
Three Laws of Trusted Data Sharing:(Building a Better Business Case for Dat...Three Laws of Trusted Data Sharing:(Building a Better Business Case for Dat...
Three Laws of Trusted Data Sharing: (Building a Better Business Case for Dat...
 
Codes and conventions of news programming
Codes and conventions of news programming Codes and conventions of news programming
Codes and conventions of news programming
 
Why coding convention ?
Why coding convention ?Why coding convention ?
Why coding convention ?
 
적당한 스터디 발표자료 만들기
적당한 스터디 발표자료 만들기적당한 스터디 발표자료 만들기
적당한 스터디 발표자료 만들기
 
Standards For Java Coding
Standards For Java CodingStandards For Java Coding
Standards For Java Coding
 
Drawing Standards & Conventions: Lecture 2
Drawing Standards & Conventions: Lecture 2Drawing Standards & Conventions: Lecture 2
Drawing Standards & Conventions: Lecture 2
 
MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016MISRA C Chairman - Device Developer Conference 2016
MISRA C Chairman - Device Developer Conference 2016
 
Codings Standards
Codings StandardsCodings Standards
Codings Standards
 
Misra c
Misra cMisra c
Misra c
 
Android code convention
Android code conventionAndroid code convention
Android code convention
 
MISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the futureMISRA C – Recent developments and a road map to the future
MISRA C – Recent developments and a road map to the future
 
Misra C Software Development Standard
Misra C Software Development StandardMisra C Software Development Standard
Misra C Software Development Standard
 
Coding standards
Coding standardsCoding standards
Coding standards
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Standard java coding convention
Standard java coding conventionStandard java coding convention
Standard java coding convention
 
Understand codes, conventions, styles and structures
Understand codes, conventions, styles and structuresUnderstand codes, conventions, styles and structures
Understand codes, conventions, styles and structures
 
Learning styles
Learning stylesLearning styles
Learning styles
 
Codes & Conventions
Codes & ConventionsCodes & Conventions
Codes & Conventions
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Basics of Functional Neuroanatomy
Basics of Functional NeuroanatomyBasics of Functional Neuroanatomy
Basics of Functional Neuroanatomy
 

Similar to Coding conventions

Code review
Code reviewCode review
Code review
Abhishek Sur
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009Yasuko Ohba
 
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
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
eddiehaber
 
高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU
Su Jan
 
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
David McCarter
 
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
David McCarter
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
walkmod
 
Raya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readabilityRaya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readability
Abdel Hady Muhammad
 
WordCamp Pune 2017- WordPress Coding standards
WordCamp Pune 2017- WordPress Coding standardsWordCamp Pune 2017- WordPress Coding standards
WordCamp Pune 2017- WordPress Coding standards
Swapnil Patil
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddSrinivasa GV
 
In-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLIn-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTML
eSparkBiz
 
Php Egypt Jan14
Php Egypt Jan14Php Egypt Jan14
Php Egypt Jan14
Hani Gamal
 
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
VinayakHospet1
 
C# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayC# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy today
Afonso Macedo
 
Tools and practices to help you deal with legacy code
Tools and practices to help you deal with legacy codeTools and practices to help you deal with legacy code
Tools and practices to help you deal with legacy code
Dennis Doomen
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
Attila Bertók
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
Perfomatix Solutions
 

Similar to Coding conventions (20)

Code review
Code reviewCode review
Code review
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
Pragmatic Patterns of Ruby on Rails - Ruby Kaigi2009
 
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)
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU高品質軟體的基本動作 101 for NTHU
高品質軟體的基本動作 101 for NTHU
 
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
 
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
 
33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod33rd degree talk: open and automatic coding conventions with walkmod
33rd degree talk: open and automatic coding conventions with walkmod
 
Raya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readabilityRaya code quality guidelines - enhancing readability
Raya code quality guidelines - enhancing readability
 
WordCamp Pune 2017- WordPress Coding standards
WordCamp Pune 2017- WordPress Coding standardsWordCamp Pune 2017- WordPress Coding standards
WordCamp Pune 2017- WordPress Coding standards
 
csharp.docx
csharp.docxcsharp.docx
csharp.docx
 
Agile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tddAgile_goa_2013_clean_code_tdd
Agile_goa_2013_clean_code_tdd
 
In-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTMLIn-Depth Guide On WordPress Coding Standards For PHP & HTML
In-Depth Guide On WordPress Coding Standards For PHP & HTML
 
Php Egypt Jan14
Php Egypt Jan14Php Egypt Jan14
Php Egypt Jan14
 
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
 
C# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy todayC# c# for beginners crash course master c# programming fast and easy today
C# c# for beginners crash course master c# programming fast and easy today
 
Tools and practices to help you deal with legacy code
Tools and practices to help you deal with legacy codeTools and practices to help you deal with legacy code
Tools and practices to help you deal with legacy code
 
Code Metrics
Code MetricsCode Metrics
Code Metrics
 
Perfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standardsPerfomatix - iOS swift coding standards
Perfomatix - iOS swift coding standards
 

Recently uploaded

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Ashish Kohli
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
JezreelCabil2
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
Aficamten in HCM (SEQUOIA HCM TRIAL 2024)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Landownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptxLandownership in the Philippines under the Americans-2-pptx.pptx
Landownership in the Philippines under the Americans-2-pptx.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

Coding conventions

  • 1. CODE STANDARDS & BEST PRACTICES Md. Ibrahim Rashid [ irashid.com ]
  • 2. Good Code Vs. Bad Code
  • 3. Good Code Vs. Bad Code  “The best applications are coded properly”  This sounds like an obvious statement, but by „properly‟, I mean that the code not only does its job well, but is also easy to add to, maintain and debug.
  • 4. Ask Yourself?  Is your code well organized and maintainable?  Is you code well documented?
  • 5. General Practices  Naming Conventions  Indentation  Brace Style  Commenting  Code consistency  Readability Vs. Compression
  • 6. What should coding standards provide?  File, class, variable naming conventions  Code formatting conventions  Guidelines for consistency across the code  Uniformity
  • 7. Naming Conventions  Class names are MixedCase  [ ex. MyClass ]  Method names are camelCase  [ ex. myMethod() ]  Constants are ALL_CAPS  [ MY_CONSTANT ]  Properties and variables are camelCase  [ ex. myMethod() ]  Non-public class members are _underscorePrefixed  [Ex. _myPrivateVariable ]
  • 8. Various Conventions Class names MyClass Method names my_function() myFunction() MyFunction Constants MY_CONSTANT Properties and my_variable myVariable variables Non-public class _my_private_variable _myPrivateVariabl members e Filenames MyFile.php myFile.php my_file.php Class Filenames ClassMyFile.php classMyFile.php class_my_file.p hp Case insensitive : MyFile.php and myfile.php are same in windows
  • 14. Indentation PHP(Drupal) Wordpress(PHP) C(K&R standard) Use an indent of 2 Use real Tab = 4 spaces, with no tabs and not spaces tabs spaces,
  • 17. Indentation  Use of Real Tabs, 4 space as Tabs, only spaces is controversial.  It‟s because same source code loaded into different editors with distinct setting will not look alike.  Use lines less than 80 characters.
  • 18. Indentation  Brace Style
  • 19. Indentation  Brace Style
  • 20. Indentation  Use of Real Tabs, 4 space as Tabs, only spaces is controversial.  It‟s because same source code loaded into different editors with distinct setting will not look alike.  Use lines less than 80 characters.
  • 22. Commenting  Always try to put comments on your code.
  • 26. Self documenting code  Use of Long Method Name that reflects the purpose of the method.  Still It needs to be commented.
  • 27. Code Readability Always try to make readable code.
  • 28. Readability Vs. Compression YES!! I saved lots of bytes. Code is now compact. There are lots of tools for making code compact. You don‟t have to write in unreadable compact form.
  • 29. Code consistency  Let a project has 3 members.  They watch this slide very carefully , and realized the importance of coding standard & best practices.  Now, they are told to do the project perfectly.  Each members uses his/her coding convention and submitted the project.  What will be the output ?
  • 30. Code consistency  Always use same standard throughout a project.  All members of a project must choose a fixed convention before starting a project.
  • 31. Learn from Others  Don’t invent your own standard. All of the issues have already been debated to death by many others.  Use an established standard • Minimize politics by choosing an external standard  • Choose a standard compatible with the libraries you use  • Use the standard as a requirement when outsourcing  Stick to the standard you establish, don‟t mix
  • 32. How To Write Unmaintainable Code Ensure a job for life ;-)  Read This Site Carefully with negating every concept.  http://thc.org/root/phun/unmaintain.html
  • 33. References  http://wiki.mozilla.org/WebDev:FrontendCodeStandards  http://na.isobar.com/standards/  http://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming _Languages/C%2B%2B/Code/Style_Conventions  http://en.wikipedia.org/wiki/Best_Coding_Practices  http://codex.wordpress.org/WordPress_Coding_Standards  http://drupal.org/coding-standards  Java Code Conventions  http://www.sitepoint.com/coding-standards/  http://www.programming4scientists.com/2008/09/26/good-code- bad-code-an-example/  http://thc.org/root/phun/unmaintain.html