Software Design · Software Engineering

Coding Guidelines

Watch lectures

Coding Guidelines

Definition

Coding Guidelines (Coding Standards) are a set of rules and best practices that developers follow while writing code, to ensure consistency, readability, maintainability, and quality across a codebase — especially important when multiple developers work on the same project.

Common Categories of Coding Guidelines

1. Naming Conventions

  • Consistent naming for variables, functions, classes (e.g., camelCase, PascalCase, snake_case)
  • Meaningful, descriptive names (avoid x, temp1, data2)

2. Code Formatting/Style

  • Consistent indentation (spaces vs. tabs)
  • Consistent bracket placement
  • Line length limits
  • Consistent use of whitespace

3. Commenting Standards

  • When and how to write comments (explain why, not just what)
  • Standard header comments for files/functions

4. Error Handling

  • Consistent approach to exceptions/error codes
  • Never silently swallow errors

5. Avoiding Bad Practices

  • Avoid deeply nested code, magic numbers, overly long functions
  • Avoid global variables where possible
  • Avoid code duplication (DRY — Don't Repeat Yourself)

6. Language-Specific Rules

  • Following idiomatic patterns of the language being used (e.g., PEP 8 for Python, Google Java Style Guide)

Why Coding Guidelines Matter

  • Consistency — code looks and reads uniformly, regardless of author
  • Readability — easier for team members (and future maintainers) to understand
  • Reduced bugs — many guidelines exist specifically to avoid common error-prone patterns
  • Easier code review — reviewers can focus on logic, not arguing over style
  • Faster onboarding — new team members can follow established patterns

Enforcement

  • Linters and static analysis tools (ESLint, Pylint, Checkstyle) automatically enforce many guidelines
  • Code reviews enforce guidelines not easily automated
  • CI/CD pipelines can block merges that violate standards

Exam tip: List 5–6 categories (naming, formatting, commenting, error handling, avoiding bad practices) with a one-line example each — a frequently asked "list and explain" theory question.

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Software Engineering modules