编程注意事项
来源:互联网 发布:linux 内核 smp 编辑:程序博客网 时间:2024/05/17 04:50
List<FundProductStockAllocationData> stockFundProductStockAllocationDataList = stockFundProductStockAllocationDataFetcher.getStockFundProductStockAllocationDataListForSingleFund(fundcode, startDate,endDate); if(stockFundProductStockAllocationDataList != null &&stockFundProductStockAllocationDataList.size()>0){ if(startDate!=null||endDate!=null){ return ResponseUtil.getResponse(stockFundProductStockAllocationDataList); } String publishDate = stockFundProductStockAllocationDataList.get(0).getPublishDate(); List<FundProductStockAllocationData> returnList = new ArrayList(); for(FundProductStockAllocationData stock:stockFundProductStockAllocationDataList){ if(publishDate==null||publishDate.equals(stock.getPublishDate())){ returnList.add(stock); }else { break; } } return ResponseUtil.getResponse(returnList);
在上述的这段比较简短的代码中犯了很多的错误。
首先逻辑判断不清楚,思维不严密。
根据传入的参数来判断是否需要进行筛选,如果没有传入时间参数则是为了获取最新的数据,需要筛选,否则不需要。
还有在进行时间是否为最新的判断时候,我开始没有考虑到字符串为空的情况,这样如果遇到字符串为空的的时候就会报空指针异常。
另外我把stock.getPublishDate()放在字符串比较函数的前面来判断字符串相等,忽略了如果再次为空的异常情况。
谨记!
0 0
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程注意事项
- 编程中的一些注意事项
- JNI编程注意事项
- 使用Unicode编程注意事项
- UDP编程特点注意事项
- MFC多线程编程注意事项
- MFC多线程编程注意事项
- Windows多线程编程注意事项
- 界面编程注意事项1
- 通过exe文件,获取程序版本号,公司名称等信息
- mysql修改密码 创建数据库 添加新用户
- 关于jxl使用心得
- 9.UITextField的基本使用
- 知识备注
- 编程注意事项
- linux
- 使用Cookie进行会话管理
- 使用正式签名打包APK,打开debug模式报错的问题解决方法
- Ubuntu 14.04 安装JDK 配置环境变量
- centos 网络配置
- Hibernate 与 JPA 小记
- MySQL删除重复记录
- 在oracle中计算表空间占用的物理空间