Principle

  1. Choose method names carefully.
  2. Don't go overboard in providing convenience methods.
  3. Avoid long parameter lists.
    1. Break the method up into multiple methods. Such as sublist element of List interface.
    2. Create helper classes to hold groups of parameters.
    3. Adapt the builder pattern form object construction to method invocation. See item 2.
  4. For parameter types, favor interfaces over classes.
  5. Prefer two-element enum types to boolean parameters.

    public enum TemperatureScale { FAHRENHEIT, CELSIUS }

Effective Java 40 Design method signatures carefully的更多相关文章

  1. Effective Java 17 Design and document for inheritance or else prohibit it

    Principles The class must document its self-use of overridable methods. A class may have to provide ...

  2. Effective Java Index

    Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st langu ...

  3. 《Effective Java》读书笔记 - 7.方法

    Chapter 7 Methods Item 38: Check parameters for validity 直接举例吧: /** * ...其他的被我省略了 * @throws Arithmet ...

  4. Effective Java 目录

    <Effective Java>目录摘抄. 我知道这看起来很糟糕.当下,自己缺少实际操作,只能暂时摘抄下目录.随着,实践的增多,慢慢填充更多的示例. Chapter 2 Creating ...

  5. 【Effective Java】阅读

    Java写了很多年,很惭愧,直到最近才读了这本经典之作<Effective Java>,按自己的理解总结下,有些可能还不够深刻 一.Creating and Destroying Obje ...

  6. Effective Java 第三版——40. 始终使用Override注解

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

  7. Effective Java通俗理解(下)

    Effective Java通俗理解(上) 第31条:用实例域代替序数 枚举类型有一个ordinal方法,它范围该常量的序数从0开始,不建议使用这个方法,因为这不能很好地对枚举进行维护,正确应该是利用 ...

  8. Effective Java 第三版——10. 重写equals方法时遵守通用约定

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

  9. Effective Java 第三版——39. 注解优于命名模式

    Tips <Effective Java, Third Edition>一书英文版已经出版,这本书的第二版想必很多人都读过,号称Java四大名著之一,不过第二版2009年出版,到现在已经将 ...

随机推荐

  1. 使用MinGW 编译 iconv 库

    原文链接: http://www.code-by.org/viewtopic.php?f=54&t=166 GNU页面 http://ftp.gnu.org/pub/gnu/libiconv/ ...

  2. 极简Unity调用Android方法

    简介 之前写了篇unity和Android交互的教程,由于代码里面有些公司的代码,导致很多网友看不懂,并且确实有点小复杂,这里弄一个极简的版本 步骤 废话不多说,直接来步骤吧 1.创建工程,弄大概像这 ...

  3. 局域网电脑Sql2008 R2无法连接到localhost 解决方案

    1.自己电脑加入加入了公司域的话,链接Sql Server服务器,用127.0.0.1或.或localhost登录时会提示如下错误: 2.解决措施: 打开Sql配置管理器->SqlServer网 ...

  4. vs 2013各个版本密钥

    Visual Studio Ultimate 2013 KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9 Visual Studio Premium 2013 KEY(密钥) ...

  5. sql: sq_helptext

    --查看表生成脚本 sql server     --- '\r'是回车,'\n'是换行  /t相当于键盘的Tab键    --- 操作系统的不同,换行符操也不同:/r Mac /n Unix/Lin ...

  6. YII 的基本CURL操作

    Order::model()->updateAll(array('merchant_id'=>'bbb'), "id in ('140868169311','1408690584 ...

  7. CentOS6.5 安装Zookeeper集群

    1.下载解压 2.配置环境变量:vi ~/.bashrc   或者   vi /etc/profile [hadoopuser@Linux01 ~]$ vi ~/.bashrc # zookeeper ...

  8. HTML JavaScript简介

    一.JavaScript简介 1.JavaScript是个什么东西? 它是个脚本语言,需要有宿主文件,它的宿主文件是HTML文件. 2.它与Java什么关系? 没有什么直接的联系,Java是Sun公司 ...

  9. 【GOF23设计模式】代理模式

    来源:http://www.bjsxt.com/ 一.[GOF23设计模式]_代理模式.静态代理 package com.test.proxy.staticProxy; public interfac ...

  10. jQuery corner 圆角插件

    jquery.corner是一款强大的圆角插件(所产生的不止只是圆角效果),兼容包括IE6.IE7.IE8.firefox.Opera .Safari.Chrome等主流浏览器,唯一的缺点是为了产生边 ...