当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 5.Introduce Explaining Variable
 

 

 ·学习使用dispatchaction    »显示摘要«
    摘要: dispatchaction继承自action类,它是一个抽象类,封装了一些基础方法,来解决使用一个action处理多个操作的能力,这就是dispatchaction最大的用途,它可以帮助我们用一个action类,封装一套类似的操作方法,节省了类的数目,同时也减轻了后期维护的困难。dispatchaction中主要包括一下几个方法:protected actionforward dispatch......
 ·intellij idea培训    »显示摘要«
    摘要: intellij idea培训 为了更好地让广大intellij idea爱好者使用intellij idea,提高程序开发效率,提升知识水平层次,为此jetbrains中国代理处(jetmaven)将组织一次idea的产品培训,主要目的是介绍idea产品的使用特性和开发技巧,并为所有的idea使用者及爱好者提供一个互相认识和学习的机会。idea作为最好的java ide,由于其资料较少,加上其......


Refactoring Notes-Refactoring Methods(3)

5.introduce explaining variable    if you have a complicated expression,put the result of the expression, or parts of the expression , in a temporary variable with a name that explains the purpose.   introduce explaining variable is particulaly valuable with conditional logic in which it is useful to take each clause of a condition and explain what the condition means a well-named temp.   another case is a long algorithm,in which each step in the computation can be explained with a temp.mechanics (1)declare a final temporary variable,and set it to the result of part of the complex expression. (2)replace the result part of the expression with the value of the temp.before:double price(){ return quantity*itemprice-math.max(0,quantity-500)*itemprice*0.05+math.min(quantity*itemprice*0.1,100.0);}after:double price(){ final double baseprice= quantity*itemprice; final double quantitydiscount=math.max(0,quantity-500)*itemprice*0.05 ; final double shipping=math.min(quantity*itemprice*0.1,100.0); return baseprice-quantitydiscount+shipping;}


...   下一页
 ·jsp 对 xml 的操作    »显示摘要«
    摘要: 本例子是参考了一些网站上有关jsp 对 xml 的操作的相关文档,又结合了一些个人的体会。例子涉及的内容是,开发的一个企业内部定餐系统后台管理端的部分代码,功能主要集中在对于餐馆基本信息的管理。例子本身是在tomcat4.01 平台下运行的b/s结构的程式。有关tomcat 的配置,这里不做说明。只讲解一下相关文件及文件夹的目录结构。目录结构说明:/tomcat/webapps/canyin/ ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE