Why ?
- For others
- For yourself, at a later point
- Makes you a professional
- And part of a professional organisation
- Part of general hygene
- Has to be acquired and nrtured
- File comment
- Function comment
- Line comment
File comment
- Identification of file
- Author
- Date
- Description
- Revision by
- Date of revision
- Description of revision
Function comment
- Function name
- Purpose
- Input parameters
- Rturn parameters
- Other functions used
- Optionally, give algorithm
- Sjort and crisp
- At end of line
- Use double slash
- Long comments, if necessary, is to be given in /* …. */ boxes
- Try to bring out the logic, don’t repeat the line…
- An art to be practiced and perfected
Coding recommendations
- Variable naming convention
- Use i,j,k… For loop indices
- Hungarian notation for all others
- Use meaningful names
- Indendation
- Explicitly indent next level
- Strive to keep minimum indentation level
- Line length
- Within normal screen and printed page
- Including comments…
- Module size
- More than one line of executable statement
- And less than a page
- Global variables
- As less as possible
- Explicitly comment use of each
- Local variables
- Do not unnecessarily define them
- Splitting into multiple files
- As far as posiible avoid
- Make self contained files
- For e.g., general subroutines can go to a common file
- Style
- Strive for simplicity
- Avoid obsucre code
No comments:
Post a Comment