《Good Habits for Great Coding》读书笔记二

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

    Page 79 - 93

  • Self Documentitng

    理解Hungarian notation

    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 and str2, 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:

    1. a title for your program
    2. a program description and maybe some program requirements
    3. your name
    4. the data the document is turned in
    5. the course name, class period/section
    6. the programming language
    7. imported packages, modules, and libraries
    8. key algorithms used
    9. strategy or design implemented in the program
    10. 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.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值