DEV Community


Posted on • Updated on

Best coding practices part 2

Best coding practices to remember.

  • Be sure to understand your problem before you decide how to solve it.

  • Be sure you understand the algorithmic method before you start the program

  • In case of difficulty, divide the problem into pieces and think of each part separately. (Divide and conquer)

  • Keep your functions short and simple; rarely should a single function be more than a page long.

  • Use techniques like "scaffolding" to simplify debugging. Scaffolding is a technique used to localize errors.

  • Keep your programs well formatted as you write them. This makes debugging easier.

  • Keep your documentation consistent with your code, and when reading a program make sure you debug he code and not just the comments.

  • Explain your program to someone else: Doing so will help you understand it better yourself.

Adapted from the book Data Structures and Program Design in C

Top comments (1)

renekkr profile image
João vitor carfe

Use techniques like Event storming, Example mapping and Feature mapping to understand the problem.
Split into bounded contexts, modules, classes and functions what can be separated.
Long classes or functions should not be a problem if do one thing really well.
Debugging should not be a problem with Automated tests, be suspicious of debug tools masters.
Explain your code to a non-programmer, really.