This list of mistakes commonly seen in undergraduate computer science programming assignments is based on a version I used while teaching introductory C++ at Bowling Green State University.
The mistakes are grouped into the following 5 categories:
Comments |
|
---|---|
1. |
|
2. |
|
3. | Comment on what your variables represent. |
Readability |
|
4. | Use meaningful variable and function names. |
5. |
Avoid `magic numbers'.
Use meaningfully named const variables instead.
|
6. |
|
7. | Do not unnecessarily repeat code in a program. Implement repeated tasks as functions or loops. |
8. |
Use modularity: main() should mostly just call the
functions that are the sub-modules of the program.
|
Clear coding |
|
9. |
Do not include unnecessary code.
Do not initialize unnecessarily — it's confusing. |
10. |
Use appropriate conditional structures
(e.g., if or
if /else or switch ).
|
11. |
|
12. | Use parameters instead of global variables to pass information to (and from) functions. |
13. | Do not use unnecessary parameters. |
Output | |
14. | Prompts to the user should be explicit, and helpful to the user. |
15. | Format your output for readability. |
16. |
|
Other | |
17. | Check your spelling. |
18. | main() always returns an int .
|
Last updated on 27 January 2005 by J. Blustein.