假设我想计算我的缺陷的累积估计。我愿意
double estimate = 0.0;
Double tEstimate = 0.0;
Collection<Defect> defects = project.getDefects(null);
for(Defect d : defects){
tEstimate = d.getEstimate();
if(tEstimate != null){
estimate += tEstimate;
}
}
这里每次调用 d.getEstimate() 都会对服务器进行回调,这意味着这段代码运行得非常慢。我想预先考虑一次性性能并下载所有信息以及缺陷对象,可能包括获取一些我不会使用的信息,但避免在循环的每次迭代期间遇到服务器回调的延迟.