Effective Java 40 Design method signatures carefully
2014-04-03 08:53 小郝(Kaibo Hao) 阅读(432) 评论(0) 编辑 收藏 举报Principle
- Choose method names carefully.
- Don't go overboard in providing convenience methods.
-
Avoid long parameter lists.
- Break the method up into multiple methods. Such as sublist element of List interface.
- Create helper classes to hold groups of parameters.
- Adapt the builder pattern form object construction to method invocation. See item 2.
- For parameter types, favor interfaces over classes.
-
Prefer two-element enum types to boolean parameters.
public enum TemperatureScale { FAHRENHEIT, CELSIUS }
作者:小郝
出处:http://www.cnblogs.com/haokaibo/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://www.cnblogs.com/haokaibo/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。