The Psychology of Quality and More |
CHAPTER 3 : General Principles
3.15 Utilize available toolsA number of software tools are available to help with the style elements of the coding task. The use of these may be standardized. Such tools can include: EditorsProgrammable editors, such as 'emacs', can be set up to automatically generate program constructs, comment blocks, etc. in your standard style, making conformance to standards easier. They can also be set up to search for common layout features. CompilersThe features of the compiler may be fully used to give warnings of possible problems. Typically, flags may be set to give different levels of warning. It is usually best to set the maximum warning level (it is better to consciously ignore a warning than not to know about it). It is also worth comparing the capabilities of such features when choosing a compiler. Search programsBy using a consistent layout, items such as function declarations may be simply listed with programs such as 'grep'. Ease of use with these programs may even drive some of the layout decisions. Language checkersPrograms like 'lint' will take a fine-toothed comb over your programs, and complain long and loud about many details that the compiler will not comment about at all. When using these, it is a good idea to document which errors are to be checked for, and which must be dealt with. Complexity checkersPrograms are available which will measure the complexity of your code. Measures such as those described by McCabe or Halstead give simple figures to indicate the complexity of code functions. Some programs will even draw maps to show graphically the knots in your functions! 'Pretty-printers''Pretty-printers' or 'beautifiers' (eg. 'cb', 'indent') will reformat the C program according to standard or selected layout standards. There is an argument which suggests that people may have their own individual layout standards, and that when they wish to read programs, they simply pass the program through the pretty-printer. This argument is limited, as style is considerably more than just layout, and even this cannot wholly be determined by syntax. Where layout shows intent, a pretty-printer cannot read the mind of the author. Pretty printers cannot add comments, create meaningful names or change obscure use of C syntax. They also take time to use (and may not be available to the person in the future wanting to look at your code). It is also not very easy to use pretty-printers on hard-copy printouts, which is probably the first port of call of a maintainer, looking for a bug. The only sensible use of pretty-printers is to bring the assorted layout of 'old' code up to a common standard. Home-brewed programsThe programming process may be assisted by writing your own programs, for example to extract the function headers of public functions into documentation.
|
Site Menu |
Quality: | Quality Toolbook | Tools of the Trade | Improvement Encyclopedia | Quality Articles | Being Creative | Being Persuasive | |
And: | C Style (Book) | Stories | Articles | Bookstore | My Photos | About | Contact | |
Settings: | Computer layout | Mobile layout | Small font | Medium font | Large font | Translate | |
You can buy books here |
And the big |