细节汇总:
- 拒绝在容器类型的命名中使用 该容器类型
List flaggedCells = new ArrayList();
As we’ll see later on, even if the container is a List , it’s probably better not to encode the container type into the name.
-相同的意思,使用一致的拼写,并保证专词专意,一次一意
Spelling similar concepts similarly is information
- 拒绝用任何数字命名
- 拒绝命名中加入 Manager , Processor、 info、data、variable (无意义的废话)
- 类名 对象名使用名词,方法名使用动词(其参数为名词)
the
function and argument should form a very nice verb/noun pair.
For example,
write(name) is very evocative. Whatever this “name” thing is, it is being “written.”
- 重载构造器时,使用静态工厂方法(相应构造器考虑用private),并按实际含义命名
(When constructors are overloaded, use static factory methods with names that
describe the arguments. For example,
Complex fulcrumPoint = Complex.FromRealNumber(23.0))
is generally better than
Complex fulcrumPoint = new Complex(23.0);
Consider enforcing their use by making the corresponding constructors private.
时间: 2024-10-11 10:53:53