Why you should put comments on code

Every person has an intrinsic test-runner in mind which keeps testing things

So even if code is self-explanatory, you should write comments

Where to Comment:

  • This is called the “Header Comment”. It should include all the defining information about who wrote the code, and why, and when, and what it should do
  1. This is called the function header and provides information about the purpose of this “sub-component” of the program.
  2. When and if there is only one function in a file, the function header and file header comments should be merged into a single comment. (See Function Header below)
  1. Any “tricky” code where it is not immediately obvious what you are trying to accomplish, should have comments right above it or on the same line with it.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store