英语学习之《Clean Code》英文交流术语整理(一)

如果有一天,有人告诉你,你将来需要和一帮只会说英语和泰语的家伙工作在一起,而你的工作是要告诉他们如何写整洁的代码,如何做重构,什么是TDD,什么是面向对象,你该怎么办?

你问我,我只能告诉你,我需要重新读一次《整洁代码》,《重构》以及《
敏捷软件开发:原则、实践和模式》的英文版,然后整理出里面可以为我使用的术语和表达。

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(做有意义的区分)

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(未完待续)

你可能感兴趣的:(英语学习之《Clean Code》英文交流术语整理(一))