Coding Style | |||||
---|---|---|---|---|---|
Consider the following 'slogan':
Programming is primarily about communicating with humans, and only secondarily about communicating with machines. Suppose that a program that you have written is to undergo some maintenance. Or suppose it is to be extended with additional functionality, or ported to another platform or re-used in another software project. Someone will have to read all or part of your code. This 'someone' might be you. But months or years may have passed since last you looked at this code. Or this 'someone' may be another programmer. And you may no longer be around to give advice about what the program does or how the program works. If your programs are to be maintainable, extendible, portable and re-usable, they must be readable and understandable.
The purpose of these StyleFile web pages is to give you ideas about good coding style. There are general remarks that can be made on this subject. |
|||||
|
|||||
The programs you write for this course will be judged against the coding style criteria that are set out in these StyleFile web pages. Read and take note! |
|||||
Identifiers Advice about the way you name entities in your programs: a prime determinant of your program's readability. |
|
||||
Variables & constants Advice about the declaration, initialisation, identifier scope, lifetime & visibility of your variables. |
|||||
Layout Advice about the formatting of your code so that its logical structure is apparent. |
|||||
Comments Advice about what makes a good comment: why should you write them, what should you write, how should you write them, when should you write them and where should you put them? |
|||||
Acknowledgments |