Code Formatting

Best Practice & Design Principles for Arduino

Last Update Unknown

Design Principles

Self-documenting code

  • Prefer good names to // comments


Well named variables

  • Say exactly what you are doing (not how)
  • Very_long_names_are_better_than_vagueness


Small well-named functions

  • Only do ONE thing in each function
  • Single-line functions are fine!


Named constants instead of magic numbers.



Naming Conventions

Constants: 

ALL_UPPER_SNAKE_CASE


Non-const Variables and Functions:

lowerCamelCase

lower_snake_case

duditiousMix_units


Arduino Libraries:

mostlyLowerCamelCase

ButTheOddExceptions: Serial, String, a few others