码迷,mamicode.com
首页 > 其他好文 > 详细

Clean code 读书笔记二

时间:2015-06-06 16:43:07      阅读:104      评论:0      收藏:0      [点我收藏+]

标签:clean

细节汇总:

  • 拒绝在容器类型的命名中使用 该容器类型
    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.

Clean code 读书笔记二

标签:clean

原文地址:http://blog.csdn.net/lemon89/article/details/46387585

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!