老早的 struts 有很多地方也被证明是不好的,但是 JF 继承下来了。
Action 与 servlet API 的耦合?
ForumService forumService = (ForumService) WebAppUtil.getService("forumService", request); 为什么不考虑 IoC?
老早的 struts 有很多地方也被证明是不好的,但是 JF 继承下来了。
Action 与 servlet API 的耦合?
ForumService forumService = (ForumService) WebAppUtil.getService("forumService", request); 为什么不考虑 IoC?
先不列很多,主要是在这里似乎看不到一些反面的讨论,这是一种不好的现象。或说是一种不正常的现象
Avoid creating an object until you know what you want:
Color getTextColor() {
Color c = null;
if (this.state < 2) {
c = new Color(...);
} else {
c = new Color(...);
}
return c;
}
Now, let's look at yours:
public PageIterator getForums(int start, int count) {
PageIterator pageIterator = new PageIterator();
try {
pageIterator = forumDao.getForums(start, count);
} catch (Exception ex) {
logger.error(ex);
}
return pageIterator;
}
Perhaps, rethrow exception will be perfect.
>老早的 struts 有很多地方也被证明是不好的,但是 JF 继承下来了。
JF在Struts上简化,通过缺省配置来替代代码Action,使用JF开发的系统,几乎无需编制Struts Action。
新版本Struts主要是Action加入Ioc,JF已经将Action打入内部机制,使用配置替代,无需代码,比引入Ioc的代码Action更简化。
JF内部使用piocContainer的Ioc,是一种autowiring IOC,这在以前文章反复介绍,J道论坛是几乎最早充分讨论Ioc设计思想的:
http://www.jdon.com/AOPdesign/Ioc.htm
关于lz提出的代码问题,会不断改进,多谢了。