123
返回列表 发新帖
楼主: justforregister

Four harmful Java idioms, and how to fix them

[复制链接]
论坛徽章:
131
乌索普
日期:2017-09-26 13:06:30马上加薪
日期:2014-11-22 01:34:242014年世界杯参赛球队: 尼日利亚
日期:2014-06-17 15:23:23马上有对象
日期:2014-05-11 19:35:172014年新春福章
日期:2014-04-04 16:16:58马上有对象
日期:2014-03-08 16:50:54马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
21#
 楼主| 发表于 2009-2-25 23:59 | 只看该作者
Conclusion                     I have argued in thisarticle that four common Java idioms should be modified. The ultimatejustification for such changes is that they will make code demonstrablyeasier to read, understand, and use -- and, in the process, they willexhibit more compassion for the mental experience of the reader. In thecase of immutability and packaging style, they will also nudge you inthe direction of improved design.
                     In summary, I suggest that the following idioms should be favored as the preferred style:
                     
  • Use a naming convention to distinguish three kinds of data, not two: local variables, fields, and method arguments.
  • Prefer the package-by-feature style over package-by-layer.
  • Prefer immutable objects over JavaBeans.
  • Order items in a class in terms of decreasing scope, with private items appearing last.
                     Ifthe arguments presented in this article are correct, then they lead toa question: Why do harmful idioms still persist in Java programmingculture, after so many years? In answer to that question, I would offerthe following speculation. Style guides and other tools published inthe early years of Java didn't have the benefit of long experience.They got most things right, but a few things wrong. This is completelynatural, and doesn't reflect poorly on their creators. Some of theseitems, which were published by Sun Microsystems, were very widelyimitated. They had a very strong influence, and were often treated asauthoritative. Perhaps they were treated with a little too muchdeference.

使用道具 举报

回复
论坛徽章:
131
乌索普
日期:2017-09-26 13:06:30马上加薪
日期:2014-11-22 01:34:242014年世界杯参赛球队: 尼日利亚
日期:2014-06-17 15:23:23马上有对象
日期:2014-05-11 19:35:172014年新春福章
日期:2014-04-04 16:16:58马上有对象
日期:2014-03-08 16:50:54马上加薪
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14
22#
 楼主| 发表于 2009-2-26 00:00 | 只看该作者
The few harmful idioms that were created in the early days of Java have persisted because they become popular, ingrained habits                        -- and perhaps because of a little bit of consensus trance or groupthink, wherein the fact that something is popular or treated as authoritative often overrides any opposing viewpoint.                     
                     WillJava programming culture gradually change these bad habits, or willthey persist, in spite of their defects? My guess is that,unfortunately, they will remain a part of Java programming culture. ButI would love to be proved wrong!

使用道具 举报

回复
论坛徽章:
5
八级虎吧徽章
日期:2008-12-08 16:10:57NBA季后赛纪念徽章
日期:2009-06-16 11:28:17
23#
发表于 2009-2-27 21:03 | 只看该作者
justforregister
闭关修炼

使用道具 举报

回复
论坛徽章:
5
八级虎吧徽章
日期:2008-12-08 16:10:57NBA季后赛纪念徽章
日期:2009-06-16 11:28:17
24#
发表于 2009-2-27 21:03 | 只看该作者
支持

使用道具 举报

回复
论坛徽章:
4
25#
发表于 2009-3-2 22:23 | 只看该作者
呵呵,头像都换了,真要闭关修炼啊

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
26#
发表于 2009-3-2 22:23 | 只看该作者
OLD! 铁锅了!

使用道具 举报

回复
论坛徽章:
350
2006年度最佳版主
日期:2007-01-24 12:56:49NBA大富翁
日期:2008-04-21 22:57:29地主之星
日期:2008-11-17 19:37:352008年度最佳版主
日期:2009-03-26 09:33:53股神
日期:2009-04-01 10:05:56NBA季后赛大富翁
日期:2009-06-16 11:48:01NBA季后赛大富翁
日期:2009-06-16 11:48:01ITPUB年度最佳版主
日期:2011-04-08 18:37:09ITPUB年度最佳版主
日期:2011-12-28 15:24:18ITPUB年度最佳技术原创精华奖
日期:2012-03-13 17:12:05
27#
发表于 2009-3-2 22:24 | 只看该作者
没品位!

使用道具 举报

回复
论坛徽章:
4
28#
发表于 2009-3-2 22:32 | 只看该作者
老虎不准打击别人积极性

使用道具 举报

回复
论坛徽章:
4
29#
发表于 2009-3-2 22:32 | 只看该作者
看来以后我也发点玩玩

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表