tutorial 1: code commenting: best practices
watch it on YouTube
Notes
- uses for commenting--best practices
- debugging--comment
out lines and then reactivate to find bugs
- documenting--use comments
to provide explanations of the code logic
or variables
- documentary commenting is useful...
- to others if multiple
people work on the code
- to you if you come
back to a project after time has passed
- keep header comments brief;
use these for versioning and
general descriptions of purpose
- use in-line (aka interlinear) comments
sparingly--best for "notes to self" and
generally you should remove these
when the project is complete.
- use for brief explanations of
functions--place right before the
function initialization line
- debugging comments should also
be removed when the project is complete
Examples
- HTML comment format
- <!--comments here--single line or multiline-->
- CSS comment format
- /*comments here--single line or multiline*/
- JavaScript comment format
- //single line comments here
- /*multi-line comments here*/