有点不爽

似乎有些小小的不爽。
原本考虑是否应该放到Blog中来,想了一想还是决定要发泄一下,如果Blog不能代表自己的观点所在,那还有什么意义?
事情的由来是这样的,我就代码编写中遇到的问题,发了内部邮件征求大家的意见。
[Channel],您好!
代码编写中遇到一个问题,大家讨论一下
编写Actioin时,我们通常是extends BaseAction implements OBDActionEx ,
需要实现save和execute方法
这俩个方式是Action的入口,需要特别控制,特别是公用模块的Action,效验应该要特别严禁。
比如,save中的method属性是否有值?execute中的strUiId是否有值?
我的解决方法是:
增加一个如下类进行控制:
package com.aish.appframe2.web.obd;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ai.appframe2.common.DataContainerInterface;
import com.ai.appframe2.web.action.BaseAction;
import com.ai.common.log.LoggerManager;
public abstract class BaseActionEx extends BaseAction implements OBDActionEx {
public void save(HttpServletRequest request, HttpServletResponse response)
throws Exception {
String method = request.getParameter("method " );
if (method == null || method.equals(" " ) ) {
throw new Exception("必须声明调用的方法");
}
save2(request,response);
}
public abstract void save2(HttpServletRequest request, HttpServletResponse response) throws Exception ;
public DataContainerInterface[] execute(HttpServletRequest request,
String strUiId, String strSetName) throws Exception {
if (strUiId == null || strUiId.equals("")) {
throw new Exception("必须声明调用的接口");
}
return execute2(request,strUiId,strSetName);
}
public abstract DataContainerInterface[] execute2(HttpServletRequest request,
String strUiId, String strSetName) throws Exception ;
public void validate(HttpServletRequest request,
HttpServletResponse response, String parameter) throws Exception{
String param = request.getParameter(parameter);
if(param == null || param.equals("")){
throw new Exception("没有接口参数("+parameter+")");
}
}
}
这样的好处是,不需要在每个Action中进行重复的代码控制,而且对应公用的都可以在这个类中进行定制。
比如validate方法可以,效验request中某个参数是否通过url传递过来(作为公用的接口,应该要进行判断)
不好的地方是,代码规范要更改,每个Action要extends这个类,实现save2和execute2方法,与原来定的有冲突。
代码编写中遇到一个问题,大家讨论一下
编写Actioin时,我们通常是extends BaseAction implements OBDActionEx ,
需要实现save和execute方法
这俩个方式是Action的入口,需要特别控制,特别是公用模块的Action,效验应该要特别严禁。
比如,save中的method属性是否有值?execute中的strUiId是否有值?
我的解决方法是:
增加一个如下类进行控制:
package com.aish.appframe2.web.obd;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ai.appframe2.common.DataContainerInterface;
import com.ai.appframe2.web.action.BaseAction;
import com.ai.common.log.LoggerManager;
public abstract class BaseActionEx extends BaseAction implements OBDActionEx {
public void save(HttpServletRequest request, HttpServletResponse response)
throws Exception {
String method = request.getParameter("method " );
if (method == null || method.equals(" " ) ) {
throw new Exception("必须声明调用的方法");
}
save2(request,response);
}
public abstract void save2(HttpServletRequest request, HttpServletResponse response) throws Exception ;
public DataContainerInterface[] execute(HttpServletRequest request,
String strUiId, String strSetName) throws Exception {
if (strUiId == null || strUiId.equals("")) {
throw new Exception("必须声明调用的接口");
}
return execute2(request,strUiId,strSetName);
}
public abstract DataContainerInterface[] execute2(HttpServletRequest request,
String strUiId, String strSetName) throws Exception ;
public void validate(HttpServletRequest request,
HttpServletResponse response, String parameter) throws Exception{
String param = request.getParameter(parameter);
if(param == null || param.equals("")){
throw new Exception("没有接口参数("+parameter+")");
}
}
}
这样的好处是,不需要在每个Action中进行重复的代码控制,而且对应公用的都可以在这个类中进行定制。
比如validate方法可以,效验request中某个参数是否通过url传递过来(作为公用的接口,应该要进行判断)
不好的地方是,代码规范要更改,每个Action要extends这个类,实现save2和execute2方法,与原来定的有冲突。
反对者则认为,这样没有多大的必要,增加了代码的复杂度??
居然认为公用接口的部分参数效验没有多大的必要?增加一个超类,居然认为是增大了代码的复杂度?
我无法理解这种短视的行为。
事实上,我不止一次的在Blog中说过,我始终认为我的水平不够,不够深也不够广。但是在小组中,甚至在上海,单纯在Java方面还没有发现让我值得钦佩的人存在。
在大公司,每往上走一步都很难。前面总有资历比你高的人在前面,除非你能比他有明显的优势,又或有千载难逢的时机,聚齐天时地利人和,否则很难被认识。我努力提高自己是技术水平,也努力压抑自己内心的渴望。
事实的结果还是我退步了,我无法命令别人做什么,但是,至少我能让自己做什么,我坚持自己的意见,除非能够拿到说服我的证据,我的代码要求尽量完美。

浙公网安备 33010602011771号