DEV Community

Sardar Mudassar Ali Khan
Sardar Mudassar Ali Khan

Posted on • Updated on

25 Clean Code Tips That You Should Be Familiar

  • 1. Format your code
  • 2. Use meaningful names
  • 3. Avoid returning NULL
  • 4. Keep class size small
  • 5. Don’t reinvent the wheel
  • 6. Use appropriate tools/IDE
  • 7. Structure your solution well
  • 8. Use proper naming convention
  • 9. Use OOP Principles in your code
  • 10.Write short methods (20-30 lines)
  • 11.Removed unused and duplicate code
  • 12.Avoid catching generic exceptions
  • 13.Don’t put everything in single class
  • 14.Use constants instead of magic numbers
  • 15.Avoid deep nested conditions and loops
  • 16.For simple if-else use ternary operator
  • 17.Don’t use too many parameters in Methods
  • 18.Refactor code and re revaluate conditions
  • 19.Use async/await for better user experience
  • 20.Unit test and test code after code reviews
  • 21.Use expression bodied methods where possible
  • 22.Use version control to maintain history of code
  • 23.Now a days libraries a quite common, choose wisely
  • 24.Don’t use a lot of comments, only add where necessary
  • 25.Follow coding and design principles (SOLID, KISS, YAGNI)
  • 26.Eliminate extra functions and create functions where possible

Top comments (0)