英語學習之《Clean Code》英文交流術語整理(一)

如果有一天,有人告訴你,你將來需要和一幫只會說英語和泰語的家伙工作在一起,而你的工作是要告訴他們?nèi)绾螌懻麧嵉拇a,如何做重構,什么是TDD,什么是面向?qū)ο螅阍撛趺崔k?

你問我,我只能告訴你,我需要重新讀一次《整潔代碼》,《重構》以及《
敏捷軟件開發(fā):原則、實踐和模式》的英文版,然后整理出里面可以為我使用的術語和表達。

So, read after me.

第一章:Meaningful Names - 有意義的命名

Use intention-revealing names(使用意圖明確(表意)的名字)

The name should tell you why it exists, what it does, and how it is used.

Implicit and explicit(含蓄(隱晦)和明確的)

The problem isn’t the simplicity of the code but the implicity of the code (to coin a phrase): the degree to which the context is not explicit in the code itself.

Intentional naming(有意圖的命名)

Number-series naming (a1, a2, .. aN) is the opposite of intentional naming. Such names are not disinformative—they are noninformative; they provide no clue to the author’s intention.

Make meaningful distinctions(做有意義的區(qū)分)

Noise words are another meaningless distinction. Imagine that you have a Product class. If you have another called ProductInfo or ProductData, you have made the names different without making them mean anything different. Info and Data are indistinct noise words like a, an, and the.

Use pronounceable names (用可以讀得出來的名字)

For example, genymdhms vs generationTimestamp

New developers had to have the variables explained to them, and then they spoke about it in silly made-up words instead of using proper English terms.

And remember, not everyone's English as "good" as you.

Noun phrase(名詞)

Classes and objects should have noun or noun phrase names like Customer, WikiPage, Account, and AddressParser. Avoid words like Manager, Processor, Data, or Info in the name of a class. A class name should not be a verb.

Verb phrase(動詞)

Methods should have verb or verb phrase names like postPayment, deletePage, or save. Accessors, mutators, and predicates should be named for their value and prefixed with get, set, and is according to the javabean standard.4

One word per concept(一詞一概念)

Pick one word for one abstract concept and stick with it.

Use solution domain names(使用解決方案領域的名字)

What programmer would not know what a JobQueue was? There are lots of very technical things that programmers have to do. Choosing technical names for those things is usually the most appropriate course.

Use problem domain names(使用問題領域的名字)

When there is no “programmer-eese” for what you’re doing, use the name from the problem domain. At least the programmer who maintains your code can ask a domain expert what it means.

Paragraphs and sentences(段落和語句)

We use the modern tools to deal with details like that so we can focus on whether the code reads like paragraphs and sentences, or at least like tables and data structure (a sentence isn’t always the best way to display data)

To be continued(未完待續(xù))

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容