VCE IT Lecture Notes by Mark Kelly, McKinnon Secondary College
Internal Documentation |
|
Internal documentation (ID) is a set of non-executable human-readable comments inserted into programming source code to make it easier to understand. Such comments are ignored by the compiler. ID serves to explain the purpose of a piece of code, identify its author, record its date of modification or version number, explain its operation, justify its existence, suggest future developments etc. Good comments don't repeat the code or explain it. They clarify its intent. Don't document the bleedin' obvious, e.g. String s = "Wikipedia"; /* Assigns the value "Wikipedia" to the variable s. */ Such documentation helps noone. Comments may also be used to explain why a block of code does not seem to fit conventions or best practices. This is especially true of projects involving very little development time, or a cunning piece of code that uses an unexpected but clever algorithm.ID is useful enough for solo programmers to remind them of what they were thinking when they created the code months or years ago. ID is especially vital for programming teams who often work on other team members' code and don't want to have to reverse-engineer some foreign code to work out what it does and how. There is also external documentation which is kept in a separate document. ID has the advantage that can't be lost, and it's immediately accessible when the code is edited. ID may be longer than the code it is in, but it does not increase the size of a compiled program: all the ID is ignored during compilation. TagsCertain tags are used in comments to assist in indexing common issues. Such tags are commonly syntax-highlighted and can be searched with common programming tools, such as the Unix grep utility. Examples of tag conventions include:
To prevent obsolete tags accumulating over time, it is best to include the date and the tag author's name in the tag comment to ease tracking.
|
Sample ID/* * Check if we are over our maximum process limit, but be sure to
10 REM This BASIC program shows the use of the PRINT AND GOTO statements.
|
Commonly found in ID...
|
| 5 types of comments to avoid making in your code |
Back to the IT Lecture Notes index
Back to the last page you visited
Created 25Nov2010
Last changed: November 25, 2010 11:32 AM
VCE IT Lecture notes copyright © Mark Kelly 2001-