From the course: Secure Coding in C

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Documenting everything

Documenting everything - C Tutorial

From the course: Secure Coding in C

Documenting everything

- [Instructor] One golden arrow in your secure coding quiver is documentation. Always comment your code, use comments to describe what the code does, but also to explain to your future self or to any fellow programmer, how the code works. I also believe that the best comments are written after you get the code correct. Sadly, programmers are often in a hurry and create useless comments, such as put five into x. This type of commenting is done out of haste or habit, and it describes nothing, as x equals five is obvious enough. I recommend writing comments after you get the code correct. Use the comment as a reason or philosophy behind your code. For example, set the number of retries. A smart approach is to use descriptive variable names, which self-comment. Retries equals five. Better still, FTP retries. For each of your own functions, document the functions purpose, its arguments and any return values. Describe valid ranges for input and output, which remind you to confirm variable…

Contents