Best Coding Practices

From Coder Merlin
Jump to navigation Jump to search
๐Ÿ‘ Best Practice ๐Ÿ‘ #261 ๐Ÿ‘
HintIcon.png
Flowcharts are your friend


๐Ÿ‘ Best Practice ๐Ÿ‘ #657 ๐Ÿ‘
HintIcon.png

Use appropriate capitalization

  • Names of types and protocols are UpperCamelCase (Pascal case)
  • Everything else is lowerCamelCase


๐Ÿ‘ Best Practice ๐Ÿ‘ #359 ๐Ÿ‘
HintIcon.png
Clarity is more important than brevity


๐Ÿ‘ Best Practice ๐Ÿ‘ #563 ๐Ÿ‘
HintIcon.png

Preconditions are your friend

  • Include sufficient information for the message to be useful


๐Ÿ‘ Best Practice ๐Ÿ‘ #174 ๐Ÿ‘
HintIcon.png

Great functions exhibit these three vital properties:

  • Easy to read and comprehend
  • Easy to debug
  • Easy to modify to solve a variation of the original task

[1]

  • No global variables
  • Appropriate capitalization
  • Appropriate and descriptive variable names
    • nouns are usually most appropriate
  • Appropriate and descriptive function names
    • verbs are usually most appropriate
  • Appropriate use of functions
    • In general, avoid mid-function exits
  • Avoid repetition
    • DRY: Do Not Repeat Yourself
    • DIE: Duplication is Evil
  • Appropriate scoping
    • Scope is no wider than absolutely necessary
  • Appropriate loops
    • Correct loop type
    • In general, avoid mid-loop exits
  • Appropriate indentation
  • Helpful whitespace
  • Appropriate placement of closing braces and parentheses
  • Deliberate and helpful comments
    • Avoid "obvious" comments
  • Avoid deep nesting
  • Avoid inappropriate nesting of functions
  • Limit line length
  • Appropriate file organization
    • Generally one class per file
  • Code is clear and concise

References[edit]


CoderMerlinโ„ข proudly recommends:
HintIcon.png

Your purchase via these links helps keep  Coder Merlinโ„ข 's orbuculum ablaze. As an Amazon Associate we earn from qualifying purchases. Thank you for your support!


Designed with pride in Silicon Valley, CA, USA