Member-only story

Write Better Codes: 100 Tips for Writing Concise, Expressive and Clean Codes

btd
6 min readDec 19, 2023

--

Writing concise and expressive code is essential for creating maintainable and efficient software. Here are 100 tips to help you achieve that:

  1. Use Meaningful Variable Names: Choose names that reflect the purpose of the variable.
  2. Follow a Consistent Naming Convention: Maintain consistency in variable, function, and class names.
  3. Avoid Single-Letter Variable Names: Except for simple loop counters, use descriptive names.
  4. Use Functions with Clear Purpose: Keep functions focused on a single task.
  5. Limit Function Length: Aim for functions that fit on a single screen (around 20 lines or less).
  6. Avoid Deep Nesting: Refactor deeply nested code for better readability.
  7. Eliminate Redundant Code: Remove duplicate or unnecessary code.
  8. Avoid Magic Numbers: Use named constants or variables instead of hardcoding numbers.
  9. Comment Thoughtful Explanations: Clarify complex sections with comments.
  10. Write Self-Explanatory Code: Strive for code that can be understood without comments.
  11. Use Whitespace Wisely: Don’t overcrowd code; use whitespace to separate logical sections.

--

--

btd
btd

No responses yet