Top Banner
Clean Code and Coding Standards
13

Clean code and Coding Standards

Jan 08, 2017

Download

Engineering

Mahesh Salaria
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Clean code and Coding Standards

Clean Code and Coding Standards

Page 2: Clean code and Coding Standards
Page 3: Clean code and Coding Standards
Page 4: Clean code and Coding Standards
Page 5: Clean code and Coding Standards

Boy Scout Rule:“Always leave the campground cleaner than you found it.”

Page 6: Clean code and Coding Standards

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

Page 7: Clean code and Coding Standards

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

Page 8: Clean code and Coding Standards

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 */)

Page 9: Clean code and Coding Standards

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.

Page 10: Clean code and Coding Standards

Error Handling (Open Discussion)

• Prefer Exceptions to Returning Error Codes • Extract Try/Catch Blocks • Don’t Return Null

Page 12: Clean code and Coding Standards

Questions?

Page 13: Clean code and Coding Standards

Thank You!Mahesh Salaria