|
Guidelines for Programming
In this unit, your code will be evaluated based on the following:
Operation
- Does the program work according to the requirements?
- How easy and intuitive is it to use?
- Is the program prone to crashing?
Source Code
- Program readability - easy to determine what the code does. Including:
- Concise code - this means not using unnecessary code. It does not mean having as few lines of code as possible. Lines of code in itself doesn't usually mean much.
- Code layout - proper indentation, control statements blocks aligned, no lines wrapped around the screen (we usually work on a screen size of 80 columns, and tab-stops of 8), blanks lines to separate subroutines and blocks, etc.
- Data structures and subroutines with appropriate names.
- Comments in the source code (for yourself and for other programmers in the future), including:
- Every script file must have a comment section at the beginning indicating what it does.
- Every subroutine must have comments at the beginning indicating what it does, what input it takes, what return values it gives - just consider that another programmer who wants to use your subroutine, should be able to do so just by reading your comments and not having to read the subroutine's code at all.
- Major data structures must have comments describing what they represent - unless it is obvious from their names.
- Future modifiability - easy to make changes in the future. Including:
- Program broken into appropriate independent sections (using subroutines if appropriate) - this makes it easy to modify, since any modifications only require changes to small sections of code. It also makes the program easier to understand.
- Efficiency - in time (executes quickly) and space (low file and memory requirements). Including:
- Good data structures
- Good use of control structures
- Good use of subroutines
- Good use of existing functions and data structures in the language
A lot of the above criteria for source code actually conflict with each other. You job as a programmer is to find a good balance.
H.L. Hiew
Unit Coordinator
Document author: H.L.
Hiew, Unit Coordinator
Last Modified: Wednesday, 28-Jan-2004 20:50:06 MST
Disclaimer & Copyright
Notice © 2004 Murdoch University
This document is relevant for semester 1, 2004 only