The last part of this section we shall look at comments. A comment is simply a bit of natural language to help the programmer remember what they were doing. In VB, comments begin with the ' Symbol. Anything after the ' symbol on a line is ignored by the translator. In JAVA comments start with // and in HTML comments start with <!--

Why are they useful? Code is rarely written by one person nor is it written in one sitting. When writing lots of code, it is easy to get confused. Comments help programmers keep track of what is going on in the code without having to read the code in detail. For example-

  1. // A can never be less than 10
  2. If a< 10 then
  3. A = 10
  4. End if

Without the comment, the programmer may have to read the rest of the code to find out that A must never be less than 10. Comments are good practice and are essential to your code. If they are not used you will loose marks, even if you have the best code in the world.

A lot of companies who write large amounts of code will have coding standards. Here they will insist on having detailed comments. They will say what needs to be commented and how. It is very important that all coders follow the same standard otherwise problems will arise when they read each others code.