The new Release 20.03 is out! You can download binaries for Windows and many major Linux distros here .
by Matt Ownby (158633)I once read that a good comment will appear on every conditional branch or loop, and a good comment will also state the INTENTION for doing something, rather than what is actually being done (because the programmer can usually figure out what is being done). For example:
// i starts at 1 instead of 0 because we don't want to process the application's name (first argument)for (int i = 1; i argc; i++){ printf("ARgument is %s\n", argv[i]);} // AND with 0xFF1234 because that is the first set of bytes in the file headerif (u & 0xFF1234){ printf("File is valid.\n");} // say file not found instead of invalid due to reason blah blah blah ...else{ printf("File not found.\n");}
A comment should tell you why something is in place rather than what the code is doing:A trival example:Don't do this:Codepublic bool CheckSmsValue(Account smsAccount){// Check tarriff is nullif (Account.Tarrif == null) return;...}Do do this:Codepublic bool CheckSmsValue(Account smsAccount){// 30-11-2005 Fixes a null reference exception that occurs later on if no reference is available.if (Account.Tarrif == null) return;...}Simon.
public bool CheckSmsValue(Account smsAccount){// Check tarriff is nullif (Account.Tarrif == null) return;...}
public bool CheckSmsValue(Account smsAccount){// 30-11-2005 Fixes a null reference exception that occurs later on if no reference is available.if (Account.Tarrif == null) return;...}