Good Programming Practice – Commenting Code
Comments |
---|
General references on comments:
SAS general references on comments:
|
Summary Points About Comments |
---|
Internal Documentation.
Are Comments Good?
Let the Code Do the Talking.
Ease of Use. Use a commenting style that is easy to maintain. Columns of characters as decorative boarders only require additional editing when a change is made. Indent and line up comments with the code they describe to maintain the code layout. SAS Syntax and Practice.
Automated Documentation.
-- Paul ok01 17:42, 27 June 2010 (UTC) |
Commenting code for Clinical Trial and Healthcare related programming |
---|
General rules for commenting suggest that commenting should say why you are doing something and should not simply describe what the code is doing. I think that the following are good reasons for using comments in Clinical programming.
Relate to a requirement in the specification or analysis plan. Related to a peculiarity of the data. Clinical data is complicated and often the code makes little sense without an understanding of the data. If it is unusual then it is definitely worth saying so. Simply coding for missing values may be self explanatory but more complicated scenarios may not be and it will be a reminder at a later date as to why you coded this way and indicate how and why the code could be updated. Complex or unusual coding is worth commenting. If you are writing code that you consider is well written, but not everyone will understand, you need to consider whether to rewrite or comment. Proc SQL , macro and use of the DOW loop often fall into this category. For example it is worth saying that your intention in a DOW loop is to retain a variable or generate an array as this will help another programmer to maintain or update the code. |
Examples of good and bad self documenting code |
---|
Text is available under the Creative Commons Attribution-ShareAlike License ; additional terms may apply. See Terms of use for details. |