SlideShare una empresa de Scribd logo
1 de 19
Conventions & Best
    Practices
    Melick Rajee Baranasooriya
 http://melick-rajee.blogspot.com/
Naming Conventions
Declaring Variables
O Local Variables (Private, Static)
  O Use Camel case
     O First letter always simple
     O Use _ in front
     O Capitalized the subsequent word
Declaring Variables ..
O Local Variables (Others)
  O Use Camel case
     O First letter always simple
     O Never user _ (this is old)
     O Capitalized the subsequent word
Declaring Variables ..
O Constants (public)
  O Use Upper Camel case
     O First letter always Capital
Declaring Properties
O Use Pascal
  O First letter always Capital
  O Capitalized the subsequent word
  O Use smart properties as much as possible
Class Names
O Always use singular form
  O Ex :- School , Person , SQLController
O First Letter Capital
Summary
Upper CAMEL       lower CAMEL       _lower CAMEL
Types & Name      Local variables   Static Fields
Spaces                              (private)
Interfaces        Local constants   Fields (private)
(ISchool)
Methods ,         Parameters
Properties ,
Events
Fields (not
private)
Constance
Static ReadOnly
Enum
Best Practices
Value Types Vs. Reference
         Types
O Value types more efficient than the
  reference.
O Use value types as possible
Use Properties instead of
    Public Variables
O Properties wrap the variables that allows
  encapsulation.
  O Can change @ once
Boxing Vs. Unboxing
O Avoid Boxing (drain performance)




O Avoid Unboxing (drain performance)
Use is and as
O Avoid Exceptions and handle null
String.Fortmat() or
   StringBuilder
Use Conditional Attributes
For each Vs. For
O Foreach generate best execution path




O Use count or length in the iteration
  O For ( .. ; .. ; Lengh)
  O For ( .. ; .. ; Count)
Try Catch
O Use try catch in the presentation layer
  O (handle it in a one place)
O Don’t use many try catch in a single code
  block (use with care)
O Use if you can handle
Method and Functions
O Don’t use too many parameters
  O (not more than 4 or 5)
  O Use struct/Class or params
O Restrict to 15,20 lines
  O Can change the logic easily
Than you.

Más contenido relacionado

Destacado (10)

Threading
ThreadingThreading
Threading
 
Oop concepts
Oop conceptsOop concepts
Oop concepts
 
JSOM and java script practices
JSOM and java script practicesJSOM and java script practices
JSOM and java script practices
 
App deployment
App deploymentApp deployment
App deployment
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Share point developement Introduction for students
Share point developement Introduction for studentsShare point developement Introduction for students
Share point developement Introduction for students
 
Apps for SharePoint 2013
Apps for SharePoint 2013Apps for SharePoint 2013
Apps for SharePoint 2013
 
SharePoint 2013 variations feature
SharePoint 2013 variations featureSharePoint 2013 variations feature
SharePoint 2013 variations feature
 
Infopath controls
Infopath controlsInfopath controls
Infopath controls
 
Beginners SharePoint introduction
Beginners SharePoint introductionBeginners SharePoint introduction
Beginners SharePoint introduction
 

Similar a Conventions & Best Practices

CodingStandardsDoc
CodingStandardsDocCodingStandardsDoc
CodingStandardsDoc
Amol Patole
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
zone
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
maheshm1206
 
javase8bestpractices-151015135520-lva1-app6892
javase8bestpractices-151015135520-lva1-app6892javase8bestpractices-151015135520-lva1-app6892
javase8bestpractices-151015135520-lva1-app6892
SRINIVAS C
 

Similar a Conventions & Best Practices (20)

CodingStandardsDoc
CodingStandardsDocCodingStandardsDoc
CodingStandardsDoc
 
Coding Best Practices
Coding Best PracticesCoding Best Practices
Coding Best Practices
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
N E T Coding Best Practices
N E T  Coding  Best  PracticesN E T  Coding  Best  Practices
N E T Coding Best Practices
 
Naming standards and basic rules in .net coding
Naming standards and basic rules in .net codingNaming standards and basic rules in .net coding
Naming standards and basic rules in .net coding
 
Ravi software faculty
Ravi software facultyRavi software faculty
Ravi software faculty
 
Ocl
OclOcl
Ocl
 
Kotlin Code style guidelines
Kotlin Code style guidelinesKotlin Code style guidelines
Kotlin Code style guidelines
 
Java conventions
Java conventionsJava conventions
Java conventions
 
Best Coding Practices in Java and C++
Best Coding Practices in Java and C++Best Coding Practices in Java and C++
Best Coding Practices in Java and C++
 
Write code like Hamlet! 15 golden rules for names in programming
Write code like Hamlet! 15 golden rules for names in programmingWrite code like Hamlet! 15 golden rules for names in programming
Write code like Hamlet! 15 golden rules for names in programming
 
Java 8 best practices - Stephen Colebourne
Java 8 best practices - Stephen ColebourneJava 8 best practices - Stephen Colebourne
Java 8 best practices - Stephen Colebourne
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
javase8bestpractices-151015135520-lva1-app6892
javase8bestpractices-151015135520-lva1-app6892javase8bestpractices-151015135520-lva1-app6892
javase8bestpractices-151015135520-lva1-app6892
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

Conventions & Best Practices

  • 1. Conventions & Best Practices Melick Rajee Baranasooriya http://melick-rajee.blogspot.com/
  • 3. Declaring Variables O Local Variables (Private, Static) O Use Camel case O First letter always simple O Use _ in front O Capitalized the subsequent word
  • 4. Declaring Variables .. O Local Variables (Others) O Use Camel case O First letter always simple O Never user _ (this is old) O Capitalized the subsequent word
  • 5. Declaring Variables .. O Constants (public) O Use Upper Camel case O First letter always Capital
  • 6. Declaring Properties O Use Pascal O First letter always Capital O Capitalized the subsequent word O Use smart properties as much as possible
  • 7. Class Names O Always use singular form O Ex :- School , Person , SQLController O First Letter Capital
  • 8. Summary Upper CAMEL lower CAMEL _lower CAMEL Types & Name Local variables Static Fields Spaces (private) Interfaces Local constants Fields (private) (ISchool) Methods , Parameters Properties , Events Fields (not private) Constance Static ReadOnly Enum
  • 10. Value Types Vs. Reference Types O Value types more efficient than the reference. O Use value types as possible
  • 11. Use Properties instead of Public Variables O Properties wrap the variables that allows encapsulation. O Can change @ once
  • 12. Boxing Vs. Unboxing O Avoid Boxing (drain performance) O Avoid Unboxing (drain performance)
  • 13. Use is and as O Avoid Exceptions and handle null
  • 14. String.Fortmat() or StringBuilder
  • 16. For each Vs. For O Foreach generate best execution path O Use count or length in the iteration O For ( .. ; .. ; Lengh) O For ( .. ; .. ; Count)
  • 17. Try Catch O Use try catch in the presentation layer O (handle it in a one place) O Don’t use many try catch in a single code block (use with care) O Use if you can handle
  • 18. Method and Functions O Don’t use too many parameters O (not more than 4 or 5) O Use struct/Class or params O Restrict to 15,20 lines O Can change the logic easily