JiveJdon Community Forums
在线530人   首页   主题表   培训咨询   标签   精华   查搜   注册    登陆 RSS
首页 » 论坛 » J2EE/JavaEE/JEE/EJB/JSF等技术讨论
 
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 2 回复 / 1
 发表新帖子   回复该主题贴
happydding

悄悄话
发表文章: 1
注册时间: 2007年07月11日 16:35
求助一个经验问题 2008年03月26日 14:17 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表
各位高手,下面这段代码,我直觉有潜在问题,但是又不知道问题在哪里,有哪位高手见过这种模式,能不能告诉我有没有潜在的隐患?就是在调用该类里面的方法时会不会有什么问题?


public class A
{
private int a = 0;
private int b = 0;

public int getAValue1(int i){

a = i*2;
return a;
}

public int getAValue2(int j){

b = i * 3
return b;

}

public int getComputeValue(int k, int m){

getAValue2(k);
getAValue1(m);
return a * b;
}

}

killer

悄悄话
发表文章: 106
注册时间: 2007年07月17日 15:40
re:求助一个经验问题 2008年03月26日 16:10 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
>>>public int getAValue2(int j){

b = i * 3
return b;

}
这个i从哪来的,这样应该会报错吧。另外,这个程序逻辑太混乱,肯定不好。命名混乱,getAValue的作用其实是设置属性值,应该写为set方法。
windshine

悄悄话
发表文章: 4
注册时间: 2008年03月26日 17:43
回复:求助一个经验问题 2008年03月26日 17:48 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
public class A
{
public int getAValue1(int i){
private int a = 0;
a = i*2;
return a;
}

public int getAValue2(int j){
private int b = 0;
b = i * 3
return b;

}
public int getComputeValue(int k, int m){

getAValue2(k);
getAValue1(m);
return a * b;
}

}

这样是不是好点?
这个主题有 2 回复 / 1Go
 
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
正在读取,请等待...
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
  发贴前查询 标签列表勿重复发表问题

RSS 手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam