Simple Guide to Comments
- Place comments before the code they describe or explain.
- Never place comments at the end of a line of code.
- Your comments should provide a description of the algorithm to be followed, so “instruct” the computer using the imperative mood:
- // Initialize the environment.
- // Greet the user.
- // Instruct the user.
- // Gather valid data.
- // Process data.
- // Display results.
- // Thank the user.
- Do not parrot the code. Assume your programmer-reader has a basic understanding of the language. For example, don’t do this:
- // Assign the value y to a new variable called x.
- int x = y;
touque.ca > Education Commons > Java > Resources > Comments
[This page last updated 2020-12-23 at 12h13 Toronto local time.]
© 2007–2024 Hersch, Bear & Company Limited. All rights reserved. “Grammar Authority,” “grammarauthority.com,” “touque.ca,” and “Canada’s Thinking Cap” are trademarks of Hersch, Bear & Company Limited. All other trademarks and copyrights are the property of their respective owners.
Privacy Policy | Licence to Copy | How to cite | Contact us