Code Reading chap1

【原著】Code Reading  -The Open Source Perspective

【作者】Diomidis Spinellisf

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+  

+                    Chapter1: Introduction

+

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


1. Make it a habit to spend time reading high-quality code that others have written.(p3)

    让花时间阅读阅读其他人写的高质量代码成为你的习惯。

-------------------------------------------------

2. Read code selectively and with a goal in your mind. Are you trying to learn new patterns, a coding style, a way to satisfy     

   some  requirements?(p4)

   有选择的阅读代码,并在大脑中有一个清晰的设定目标(译注:关于带着什么目的去阅读何种代码的目标)。你试图去学习新的模式么?是去学    一种代码风格么?是去学一种满足一些需求的方式么?

--------------------------------------------------

3. Notice and appreciate the code's particular nonfuntional requirements that might  give rise to a specific implementation             style.(P4)

    注意到并且去欣赏代码相关的特定的非功能性需求,这些需求可能会导致特定的实现风格。

---------------------------------------------------

4.When working on exsiting code, coordinate your efforts with the authors or maintaniners to avoid duplication of work or bad    feelings.(P5)

   当处理已经存在的代码时,要和代码作者以及维护者(译注:就代码)取得协调,从而避免重复工作或者不良感觉。

---------------------------------------------------

5. Consider the benefits you receive from open-source software to be a loan; look for ways to reply it by contribute back to       the open-source community(P5).

    将你从开源软件那里获取的好处看作是一种别人给你的贷款;努力去找寻回报开源社区的方式(译注:资金支持,代码贡献,等等)。

---------------------------------------------------

6. In many cases if you want to  know "how'd they do that?" there's no better way than reading the code.(P5)

    在许多如果你想知道“他们是怎么干的?”(译注:程序为什么以这样或那样的方式执行?背后的逻辑是什么?)的情况下,没有比阅读代码更       有效的方式来了解这个问题了。

---------------------------------------------------

7. When looking for a bug, examing the code from the problem manifestation to the probelm source. Avoid following unrelated     paths(P6)

    当你寻找bug时,从问题表现出来的地方开始检查,直至问题源头。要避免跟进到不相关的路径中去。

---------------------------------------------------

8. Use the debugger, the compiler's warnings or symbolic code output, a system call tracer, your database's sql logging              facility, packet dump tools, and windows message spy programs to locate a bug's location.(P6)

    使用调试器, 编译器的警告或者符号代码输出,系统调用追踪器, 你数据库的SQL日志工具, 包的dump 工具, 以及windows 消息侦测程     序,用以上种种来定位发生bug的地点。

---------------------------------------------------

9. You can  successfully modify large well-structured systems with only a minimal understanding of their complete                      functionality.(P7)

   你可以成功的对大型的而且是格式优良的系统进行修改,而且只需要对该系统的完整功能集有一个最低限度的了解即可。

---------------------------------------------------

10. When adding new functionality to a system, your first task is to find the implementation of a similar feature to use as a           template for the one you will be implementating.(P7)

      当对一个系统增加一个新的功能时,你的首要任务是找到一个有类似特征的实现,去作为模板使用到你将要实施的系统之新增功能中。

---------------------------------------------------

11. To go from a feature's functional specification to the code implementation, follow the string messages or search the code         using keywords.(p7)

      为了从一个特征的功能说明深入到代码实现,需要追随字符串消息(译注:?)或者使用关键字来查找代码。

---------------------------------------------------

12. When porting code or modifying interfaces, you can save code-reading effort by directing your attention to the problem           areas identified by the compiler.(P8)

      当移植代码或者更新接口的时候,你可以集中精力到编译器为你找出的问题范围,从而节省在阅读代码上所耗费的精力。

---------------------------------------------------

13. When refactoring, you start with a working system and want to ensure that you will end up with a working one. A suit of         pertinent test cases will help you satisfy this obligation.(P8)

      当重构的时候,你以一个可以工作的系统作为开始,并希望确保你能够以一个可以工作的新系统结束。相关的测试用例套件将帮助你满足这        个期望(译注:在这里作者指需要关注UNIT测试)。

---------------------------------------------------

14. When reading code to search for refactoring opportunities, you can maximize your return on investment by starting from         the system's architecture and moving downward, looking at inicreasing levels of details.(P9)

      当你阅读代码以查找是否存在重构的机会时,你可以通过从系统架构作为开始,向下移动逐级深入到不断增多的细节中去,从而从该投资         (译注:该投资指该种情况下的代码阅读方式)中获得最大化的回报。

---------------------------------------------------

15. Code reusablility is a tempting but elusive concept; limit your expectations and you will not be disappointed.(P9)

     代码重用是一种诱人的但是很难懂得的那么一种概念;恰当的约束一下自己的期望(译注:指代码重用方面的不恰当期望),而且你不会失望      的。

---------------------------------------------------

16.  If the code you want to use is intractable and difficult to understand and isolate, look at larger granularity packages or            different code.(P9)

       如果你想使用的代码是倔强难治的,难于理解的以及孤立的(译注:代码缺少内部文档或者外部文档),那么就去寻找更大粒度的包或者干       脆使用不同的代码(译注:没有文档注释的代码命运是悲惨的。)。

---------------------------------------------------

17. While reviewing a software system, keep in mind that it consists of more elements than executable statements. Examing         the file and directory structure, the build and configuration process, the user interface, and the system's documentation.         (P10)

      当你检验一个软件系统时,记住一点:软件系统的组成有比可执行状态更多的元素。检验软件系统的时候需要检查文件与目录结构, 构建以       及配置过程,用户接口,以及系统文档。

---------------------------------------------------

18. Use software reviews as a chance to learn, teach, lend a hand, and receive assistance.(P10)

     把软件检验看作是一个学习的机会,一个教育的机会,一个帮助以及获取帮助的机会。

+++++++++++++++++++++++++end of Chap1++++++++++++++++++++++++++++++++

原文地址:https://www.cnblogs.com/parsifal/p/2086262.html