Code Reading chap10

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

+  

+                    Chapter10: Code Reading Tools

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

223. Use lexical tools to efficiently search for patterns in a large source code file or across many files.(P.340)

       运用词典工具来有效的查找大型源代码文件或者跨许多文件的模式 。

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

224.  Use a program editor and regular expression search commands to browse large  source

        code files.(p.340)

         使用程序编辑器以及正则表达式查找命令去浏览大型源代码文件。         

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

225.  Browse source files with your editor in read—only mode.(P.341)

         在你的编辑器中去浏览源代码文件时,需要以只读模式进行。

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

226.   You Can locate a function definition by using a regular expression search of the 

          type ^ function name.(P.341)

         你可以通过使用^函数名类型的正则表达式搜索 ,去定位一个函数的定义。

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

227.  Use regular expression character classes to look for variables with names that follow a

        specific pattern.(P.342)

        使用正则表达式字符类去查找跟随在特定模式后的变量。

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

228. Use regular expression character classes with negation to avoid false-positive matches.p.342)

         使用正则表达式字符类的否定形式去避免假正值匹配。

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

229.  Search for symbols appearing together on the same line by using the regular  expression

        symbol1* symbol2(P.343)

        查找在同一行中一起出现的符号话,就使用正则表达式  symbol1* symbol2。        

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

230. Use your editor’s tags facility to quickly locate entity definitions.(P.343)

       使用你的编辑器的标签工具来快速的定位实体定义的地方。

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

231.  You can enhance the browsing functionality of your editor with specialized tag creation tools.(P.344)

        你可以用特殊的标签生成工具去强化你的编辑器的浏览功能  

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

232.   You can obtain a bird’s-eye view of the source code structure by using an editor’s outline view.(p.345)

         你可以通过使用编辑器的轮廓视图来获取鸟瞰源代码结构这样的能力。(译注,类似ECLIPSE 中 CTRL+0打开的类的概览)          

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

233.  Use your editor to detect matching parentheses,brackets,and braces.(P.345)

        使用你的编辑器去检测匹配圆括号,方括号,花括号。

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

234.  Search for code patterns across multiple files by using grep.(P.346)

        使用grep去搜索跨越多个文件的代码模式。

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

235.   Locate  symbol declarations,definitions, and uses by using grep.(p.7)

        通过使用grep去定位符号声明,定义,以及引用。

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

236.  When you are not sure what exactly you are looking for,search the program  source code for

         the stems of key words.(p.347)

         当你不是很确定你在找的是什么时,那么就从关键字作为开始去查找程序的源代码。

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

237.   Pipe the output of other tools through grep to isolate the items you are looking  for.(p.347)

         将其它工具的输出通过grep去管道化,从而隔离了你所查找的明目。

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

238.   Pipe the output of grep to other tools to automate sophisticated processing tasks。(P347)

         将grep 的输出管道化到其它工具,从而自动化的以精致的方式去执行任务。

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

239. Reuse the results of a code search by stream—editing the grep output.(P.348)

        通过流编辑grep 的输出,从而去重用一次代码查询的结果 。  

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

240.  Filter spurious grep output by selecting output lines that do not match the noise

        pattern(g rep-v).(p.350)

        通过选择不匹配噪音模式(grep -v),去过滤伪造的grep输出。

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

241.  Match source code against lists of strings by using fgrep.(P.353)

         通过使用fgrep去匹配对立于字符串列表的源代码。

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

242.   Search through all comments and through the code of languages with case— insensitive

          identifiers(for example,Basic)using case—insensitive pattern matching(grep-i).(P.354)

          在所有注释上的搜索,以及在大小写不敏感的标识符上的搜索(比如, Basic),就要使用大小写不敏感

          的匹配模式(grep -i)。

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

243.   Create checklists of files and line numbers that match a given regular expression   by using

         the grep—n command-line switch.(P.354)

         生成文件检查列表,以及通过使用grep -n 命令行转换去匹配一给定的表达式的行号。          

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

244. Compare different versions of a file or program by using diff.(P.355)

       通过使用diff去比较一个文件或者程序的不同版本

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

245.  When running the diff command,you Can use diff -b to make the file comparison algorithm ignore

         trailing blanks,一w to ignore all whitespace differences,and -i  to make the file comparison case

         insensitive.(p.356)

        当运行一个diff 命令时, 你可以使用diff -b使文件比较算法忽略掉尾空格, 使用diff  -w 去忽略掉所有空格键差异,

        使用-i 使文件比较对大小写是敏感的。

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

246.  Do not be afraid to create your own code—reading tools.(P.357)

        不要害怕生成你自己的代码阅读工具。

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

247.   When developing your own code—reading tool:exploit the capabilities of modern   rapid—prototyping

         languages,start with a simple design and gradually improve it, use heuristics based on the

         lexical structure of the code,be prepared to tolerate  some output noise or silence,and use other

        tools to preprocess your input or   postprocess your output.(P.359)

        当开发你自己的代码阅读工具时:利用现代快速原型语言的能力,以简单的设计始,慢慢的发展, 使用基于词典结构的

       代码之启发式方式 ,抱有准备忍受一定程度的输出噪音以及杳无音讯的心,并使用去其它工具来预处理你的输入

       或者你输出的尾处理。

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

248.  When reading code,make the compiler your friend:specify the appropriate level  of compiler

         warnings and carefully evaluate the results.(P.360)

        当阅读代码的时候, 让编译器成为你的朋友:确定编译器警告的合适级别,以及小心翼翼的评估其结果。 

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

249.   Use the C preprocessor to untangle programs that abuse it.(P.361)

         使用C预处理器去整顿滥用它(译注:它指?)的程序。

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

250.   To definitely understand how the compiler treats a particular piece of code,look at the generated                    

          symbolic(assembly) code.(P.362)

          为了完全理解一个编译器是如何对待特定片段的代码的, 需要去看一下生成的符号代码(汇编)。

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

251.   You can obtain a clear picture of a source file’s imports and exports by examining the

         corresponding object file symbols.(P.364)

          你可以通过检查相应的对象文件符号去获取有关源文件的输入与输出的清晰图景。 

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

252.   Use source code browsers to navigate through large code collections and object classes.(p.365)

         用源代码浏览器去在大块的代码集合以及对象类上浏览。

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

253.   Resist the temptation to beautify foreign code to your coding standards;gratuitous formatting

         changes create divergent code bases and hinder organized maintenance.(P.367)

         抵制美化外部代码到你的代码标准这样一种诱惑;无理由的格式改变会生成有分歧的代码成分,以及阻止有组织的维护。

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

254.    Program pretty—printers and editor syntax coloring can make source code more  readable.(p.368)

          程序的格式优美以及 编辑器语法高亮可以使得源代码更可读。

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

255.   The program cdecl will translate inscrutable C and C++ type declarations into

          plain English(and vice versa).(p.368)

          cdecl程序会转换 难以理解的 C 与 C++类型声明到无格式的英语(反之亦然)。         

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

256.   You can gain valuable insight on how the program operates by actually executing (p.370)

         你可以通过实际执行程序来获得关于深入到程序怎样运行的评估。

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

257.   System call,event,and packet tracing tools can improve your understanding of 

         a program’s operation.(P.371)

         系统调用, 事件, 包追踪工具可以提升你关于一个程序操作的理解。

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

258.   Execution profilers let you target your optimization efforts,verify your input  data coverage,

         and analyze the operation of algorithms.(p.372)

         执行剖析工具使得你可以对你的优化努力进行定位,以及验证你的输入数据的覆盖度,以及分析算法的执行过程。

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

259.   Look for lines that are never executed to find weaknesses in your test coverage

         and amend your test data(P.372)

        查找那些你从来没有去执行的行,从而发现你的测试覆盖中的弱项以及改进你的测试数据。

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

260.   Tb explore every detail of the dynamic operation  of a program you are examining,

          run it under a debugger.(P.3 73)

         为了探索到一个你所检查的程序的动态执行之所有细节, 就需要在一个调试器下运行它。

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

261.  Print on paper code you find hard to understand.(p.3 75)

        把你难于理解的代码打印到纸张上。

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

262.  Draw diagrams to depict the code’s operation.(p.375)

        画图以描绘代码的操作。

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

263.   You can always get a better understanding of a piece of code by explaining it to

        someone else.(P.3 75)

        你总是可以通过把一段代码解释给别人听,以获取该段代码的更好理解。

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

264.   To understand complicated algorithms or subtle data structures,select a peaceful  and quiet

         environment and concentrate deeply without drawing any help from  computerized or

         mechanical aids.(p.376)

         为了理解复杂的算法或者是微妙而敏感的数据结构, 选择一个安静的环境以及集中注意力,不要试图

        从任何电脑控制的或者机械的地方取得帮助。

++++++++++++++++++++++++++end of chap10+++++++++++++++++++++++++++++++

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