-
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
str1andstr2, 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 发布
本文介绍了代码自我文档化的重要性,包括使用清晰的函数间隔、避免相似变量名,以及采用外部文档记录程序信息如标题、描述、作者等。同时,文章强调了增量开发(Step-Wise Refinement)的概念,通过选择描述性的函数名来辅助读者理解程序设计,从而减少阅读代码的需求。

1万+

被折叠的 条评论
为什么被折叠?



