DEV Community


Posted on • Updated on

Best coding practices.

Best coding practices.

  • Always name your variables and functions with the utmost care and explain them thoroughly.
  • Keep documentation concise but descriptive.
  • The reading time for programs is much more than the writing time. Hence, the code must be such that the reading is easier to do. A little more time spent in making the code lucid goes a long way in saving time later.
  • Each function must do only one task but do it well.
  • Treat each function as a BlackBox- each function must hide something.
  • Keep the connections simple. Avoid global variables wherever possible.
  • If you use global variables, document them thoroughly. Not doing so will cause side effects.
  • The quality of the test data is more important than its quantity.
  • Program testing can show the presence of bugs, but never their absence. You cannot ever guarantee 100% correct code.

Adapted from the book Data Structures and Program Design in C

Top comments (0)