Clean Code and Coding Standards
Boy Scout Rule: “Always leave the campground cleaner than you found it.”
Meaningful Names (Open Discussion) • Avoid Disinformation • Make Meaningful Distinctions • Use Pronounceable Names • Use Searchable Names • Member Prefixes (Avoid encodings) • Hungarian Notation (Avoid encodings) • Avoid Mental Mapping • Class and Method Names • Pick One Word per Concept
Functions (Open Discussion) • Small functions • Do One Thing • One Level of Abstraction per Function • Reading Code from Top to Bottom • Use Descriptive Names • Function Arguments • Don’t Repeat Yourself (DRY) • Structured Programming • Indentation
Comments (Open Discussion) • Comments Do Not Make Up for Bad Code // don’t comment bad code, rewrite it! • Explain Yourself in Code • Legal Comments • Informative Comments • Explanation of Intent • Clarification • Warning of Consequences • TODO Comments • Bad comments examples (/* The ****** variable */)
Formatting (Open Discussion) • Team Rules: every programmer has his own favorite formatting rules but if he works in a team then the team rules. • Single template and color scheme for whole team.
Error Handling (Open Discussion) • Prefer Exceptions to Returning Error Codes • Extract Try/Catch Blocks • Don’t Return Null
Coding Standards • Java: http://www.oracle.com/technetwork/java/codeconvtoc- 136057.html • PHP http://www.php-fig.org/psr/psr-2/ • C# https://msdn.microsoft.com/en-us/library/ff926074.aspx • Android https://source.android.com/source/code-style.html • Objective C https://github.com/raywenderlich/objective-c-style-guide • Swift https://github.com/raywenderlich/swift-style-guide • AngularJS https://google.github.io/styleguide/angularjs-google- style.html
Questions?
Thank You! Mahesh Salaria

Clean code and Coding Standards

  • 1.
    Clean Code andCoding Standards
  • 5.
    Boy Scout Rule: “Alwaysleave the campground cleaner than you found it.”
  • 6.
    Meaningful Names (OpenDiscussion) • Avoid Disinformation • Make Meaningful Distinctions • Use Pronounceable Names • Use Searchable Names • Member Prefixes (Avoid encodings) • Hungarian Notation (Avoid encodings) • Avoid Mental Mapping • Class and Method Names • Pick One Word per Concept
  • 7.
    Functions (Open Discussion) •Small functions • Do One Thing • One Level of Abstraction per Function • Reading Code from Top to Bottom • Use Descriptive Names • Function Arguments • Don’t Repeat Yourself (DRY) • Structured Programming • Indentation
  • 8.
    Comments (Open Discussion) •Comments Do Not Make Up for Bad Code // don’t comment bad code, rewrite it! • Explain Yourself in Code • Legal Comments • Informative Comments • Explanation of Intent • Clarification • Warning of Consequences • TODO Comments • Bad comments examples (/* The ****** variable */)
  • 9.
    Formatting (Open Discussion) •Team Rules: every programmer has his own favorite formatting rules but if he works in a team then the team rules. • Single template and color scheme for whole team.
  • 10.
    Error Handling (OpenDiscussion) • Prefer Exceptions to Returning Error Codes • Extract Try/Catch Blocks • Don’t Return Null
  • 11.
    Coding Standards • Java:http://www.oracle.com/technetwork/java/codeconvtoc- 136057.html • PHP http://www.php-fig.org/psr/psr-2/ • C# https://msdn.microsoft.com/en-us/library/ff926074.aspx • Android https://source.android.com/source/code-style.html • Objective C https://github.com/raywenderlich/objective-c-style-guide • Swift https://github.com/raywenderlich/swift-style-guide • AngularJS https://google.github.io/styleguide/angularjs-google- style.html
  • 12.
  • 13.