重构到设计模式的经典案例,超完美详细(java源码)

上传者: wunglee | 上传时间: 2021-07-08 03:11:45 | 文件大小: 23KB | 文件类型: RAR
/* * 原始需求背景: * 网宿CDN要按月收取客户的服务费用,根据流量的大小、 * 服务的类型等,收取不同的费用,收费规则如下: * web应用:1000元/M * 流媒体应用:1000元/M*0.7 * 下载应用:1000元/M*0.5 * 月末打印报表时,要罗列每个用户每个频道的费用、客户总费用, * 还要打印该客户的重要性指数,重要性指数=网页流/100+下载流量/600; * * 需求变更场景: * 系统已经开发出来了,接下来,运维部门现在希望对系统做一点修改, * 首先,他们希望能够输出xml,这样可以被其它系统读取和处理,但是, * 这段代码根本不可能在输出xml的代码中复用report()的任何行为,唯一 * 可以做的就是重写一个xmlReport(),大量重复report()中的行为,当然, * 现在这个修改还不费劲,拷贝一份report()直接修改就是了。 * 不久,成本中心又要求修改计费规则,于是我们必须同时修改xmlReport() * 和report(),并确保其一致性,当后续还要修改的时候,复制-黏贴的问题就 * 浮现出来了,这造成了潜在的威胁。 * 再后来,客服部门希望修改服务类型和用户重要性指数的计算规则, * 但还没决定怎么改,他们设想了几种方案,这些方案会影响用户的计费规则, * 程序必须再次同时修改xmlReport()和report(),随着各种规则变得越来越复杂, * 适当的修改点越 来越难找,不犯错误的机会越来越少。 * 现在,我们运用所学的OO原则和方法开始进行改写吧。 */

文件下载

资源详情

[{"title":"( 22 个子文件 23KB ) 重构到设计模式的经典案例,超完美详细(java源码)","children":[{"title":".project <span style='color:#111;'> 597B </span>","children":null,"spread":false},{"title":"pom.xml <span style='color:#111;'> 7.07KB </span>","children":null,"spread":false},{"title":"checkstyle.xml <span style='color:#111;'> 6.11KB </span>","children":null,"spread":false},{"title":".settings","children":[{"title":"org.eclipse.jdt.core.prefs <span style='color:#111;'> 334B </span>","children":null,"spread":false},{"title":"org.maven.ide.eclipse.prefs <span style='color:#111;'> 271B </span>","children":null,"spread":false}],"spread":true},{"title":"src","children":[{"title":"test","children":[{"title":"resources","children":null,"spread":false},{"title":"java","children":[{"title":"com","children":[{"title":"chinanetcenter","children":[{"title":"example","children":[{"title":"charge","children":[{"title":"version2","children":[{"title":"UserTest.java <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false}],"spread":true},{"title":"version6","children":[{"title":"UserTest.java <span style='color:#111;'> 2.27KB </span>","children":null,"spread":false}],"spread":true},{"title":"version1","children":[{"title":"UserTest.java <span style='color:#111;'> 2.08KB </span>","children":null,"spread":false}],"spread":false},{"title":"version3","children":[{"title":"UserTest.java <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false}],"spread":false},{"title":"version4","children":[{"title":"UserTest.java <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false}],"spread":false},{"title":"version0","children":[{"title":"UserTest.java <span style='color:#111;'> 2.08KB </span>","children":null,"spread":false}],"spread":false},{"title":"version5","children":[{"title":"UserTest.java <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":"main","children":[{"title":"resources","children":null,"spread":false},{"title":"java","children":[{"title":"com","children":[{"title":"chinanetcenter","children":[{"title":"example","children":[{"title":"charge","children":[{"title":"version2","children":[{"title":"User.java <span style='color:#111;'> 2.62KB </span>","children":null,"spread":false}],"spread":true},{"title":"version6","children":[{"title":"User.java <span style='color:#111;'> 4.24KB </span>","children":null,"spread":false}],"spread":false},{"title":"version1","children":[{"title":"User.java <span style='color:#111;'> 2.51KB </span>","children":null,"spread":false}],"spread":false},{"title":"version3","children":[{"title":"User.java <span style='color:#111;'> 3.69KB </span>","children":null,"spread":false}],"spread":false},{"title":"version4","children":[{"title":"User.java <span style='color:#111;'> 3.11KB </span>","children":null,"spread":false}],"spread":false},{"title":"version0","children":[{"title":"User.java <span style='color:#111;'> 3.56KB </span>","children":null,"spread":false}],"spread":false},{"title":"version5","children":[{"title":"User.java <span style='color:#111;'> 3.97KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true},{"title":".pmd <span style='color:#111;'> 22.25KB </span>","children":null,"spread":false},{"title":".classpath <span style='color:#111;'> 693B </span>","children":null,"spread":false},{"title":".checkstyle <span style='color:#111;'> 299B </span>","children":null,"spread":false}],"spread":true}]

评论信息

  • weixin_43288807 :
    只是代码……以为是文档
    2020-06-17
  • renxiao2005 :
    重构别人的代码,真的是一件痛苦的事情。好痛苦。首先要理清别人的思路,然后再找出不足。最后……
    2016-09-11
  • lj_w :
    资源不错,可以参考
    2014-01-10

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明