Getters and Setters Are Evil or Not Evil?
来源:互联网 发布:中国指数研究院数据库 编辑:程序博客网 时间:2024/05/18 22:11
在JavaLobby看到了Bozhidar Bozhanov的一篇文章Getters and Setters Are Not Evil,evil or not evil, 这是个问题,set 和 get方法主要是为了适应JavaBeans规范产生的,Joshua Bloch也在他著名的书《Effective Java》中进行了含蓄的批评,不过迄今为止Java语言没有针对这个情况做很好的改善,使用Annotation标注的方式实现属性更是走入了一个极端,让简单的方式变得更复杂,是使用统一的方法命名方式还是在方法上加Annotation呢?显然是前者更直观,不得不承认C#在这个方面做的更好,属性的声明和实现在一个块中,减轻了程序员的负担!
Rémi Forax的属性提议就是模仿C#语言的(http://weblogs.java.net/blog/forax/archive/2007/01/property_reload.html),看起来还不错,能够节省不少代码,针对域对象和类似控件的Bound属性,只需要声明所有的Field就行了!
记住KISS原则:Keep It Simple and Stupid.
- Getters and Setters Are Evil or Not Evil?
- JavaScript Getters and Setters
- Evil
- Evil
- Java Reflection - Getters and Setters
- Java Reflection - Getters and Setters
- Singletons Are Evil
- Utility Classes Are Evil
- Why Singletons are Evil
- Civil and Evil Engineer
- Civil and Evil Engineer
- Java Reflection(六):Getters and Setters
- eclipse Generating Getters and Setters Failed
- Java Reflection(六):Getters and Setters
- 【eclipse】generate getters and setters错误
- Java Reflection(六):Getters and Setters
- Singletons in Cocoa, are they evil?
- Singletons in Cocoa, are they evil?
- 使用git bisect去定位引入bug的代码
- 内部类
- iis 集群服务的安装失败,特定错误代码为0x5 安装程序会继续
- String,StringBuffer与StringBuilder的区别??
- ios 开发学习笔记(一)
- Getters and Setters Are Evil or Not Evil?
- Java的native关键字
- 关于程序员如何打基础
- 2011-10-15 17:30:12
- UML9种图
- ios 5.0中关于UINavigationBar, UIToolbar, and UITabBar - drawRect:调用问题
- IP地址的分类,有效主机范围,私有地址
- 开通博客三天之内不允许发表文章
- bada开发基础之内存管理