Skip to content

Coding Guidelines

Scenario

  • I like writing code my way, but it's different from the rest of my team

Key Takeaways

  • Guidelines are project dependent - ask your leads
    • If you are a lead, come up with a starting set of guidelines (they can always be updated later)
  • Refine guidelines through the Feedback process
  • Enforces consistency between developers and within individual code
  • If the style is enforce programmatically, making changes is easy
  • Propose guidelines if none exist
    • It's a lot easier to get buy-in on a draft than asking for one to be created
  • Don't get too bogged down by guidelines. They are nice to have, but shouldn't halt progress
  • Use tools to automatically format code
    • VSCode - "Format code" in toolbar

Coding Guidelines

  • Naming conventions for variables and functions
    • Make names easy to understand
    • Avoid ambiguous abbreviations
  • Magic values
    • Unclear why they were chosen, units
  • Keep use case in mind
    • Consider context when developing and commenting
    • If on a sensitive project, don't use sensitive terminology or terms in comments on an otherwise non-sensitive project - saves review and cleanup time later
  • Formatting
    • Tabs vs spaces (this is important in some languages, like Python)