-
Overview
Page 79 - 93
-
Self Documentitng
Certainly functions should be separated by at least a blank line. Placing a line of dashes or stars between functions is help for reading on paper.
begin/end, start/stop are better than start end
We should avoid similar names like
str1
andstr2
, because it is too easy to type one for the other, and the difference between the names is not meaningful.Successive commands can be written on the same line provided that, logically, they belong together. The question, as always, is readability.
-
Use external documentation,
in a neat box, place some of the following information:
- a title for your program
- a program description and maybe some program requirements
- your name
- the data the document is turned in
- the course name, class period/section
- the programming language
- imported packages, modules, and libraries
- key algorithms used
- strategy or design implemented in the program
- external files
-
Step-Wise Refinement
理解incremental development on Programming
One way to self-document your code is to use top-down design, a form of structured programming also called step-wise refinement, the goal of which is to choose function names so descriptive that a reader can easily understand the design of a program without reading much computer code or comments.
《Good Habits for Great Coding》读书笔记二
最新推荐文章于 2024-03-04 20:59:25 发布