HOW TO WRITE CLEAN CODE

Revision en2, by ilexis, 2026-04-08 17:20:41

Hello everyone! In contests when i get the code wrong, one of the things that put me down is styling. In other words,the code works,sometimes,but when something goes wrong and i start debugging, it's very hard to read your own code under the contest conditions. There are lots of top-rated users who have well styled code (eg jiangly) and I just cant write like that.

Questions for you:

How do you manage to have clear variable names that are still easy to type? Do you make many macros/defines or is it a bad practice to do so? Do you have some tips on speeding up debugging process (I write lots of cerrs and doing so is pretty slow)?

Do you use auto-formatter or do manually all formatting? if you use one can you tell me the name or provide the link to it becouse i cant find one. Of course, in CP, clean code doesn't play an as big role as knowledge of algorithms, but I guess it may help me save my time and avoid bugs.

(also my dad said i am writing dirty code and gave me a total of 1000 pages of books about clean coding so i now have to write clean code too)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ilexis 2026-04-08 17:20:41 8
en1 English ilexis 2026-04-08 14:13:39 1102 Initial revision (published)