Clean Code 读书笔记二
2015-06-06 13:22
288 查看
细节汇总:
拒绝在容器类型的命名中使用 该容器类型
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.
拒绝在容器类型的命名中使用 该容器类型
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.
相关文章推荐
- jquery call and apply
- c语言指针详细解释
- css3样式绘制腾讯企鹅
- 资深投资人: VC的“增值平台”就是一坨狗屎
- 学习docker
- HTML5古典卡带音乐播放器
- shell变量详解
- html5获取地理位置信息4种方式详解
- Win10正式版授权不绑定个人微软账号 可以被任何账户使用
- 基于IP地址的HTML5地理位置定位 Geolocation API实例
- php yield
- css3大小单位px、pt、em和rem的区别
- FTP命令详解(含操作实例)
- web.xml配置详解
- 行内元素与块级元素比较全面的区别和转换
- RDO连接 发现服务器蓝屏
- css3+js实现iphone5s手机桌面效果
- 针对商业模式的七伤拳
- 输出一个公共子序列
- HDOJ还是畅通工程之--prim算法