当前位置:网站首页>代码复查
代码复查
2022-06-28 21:47:00 【Yuyy】
本文最后更新于 781 天前,其中的信息可能已经有所发展或是发生改变。
new Date(xx.getTime() + 5 * 1000)时间操作,请用日历类或 java 8 的时间类,减少多余new Date对象创建Arrays.asList(xx).stream()自己看一下 Arrays.asList() 的源码吧,Arrays.stream(new Object[]{spVO}) 不香吗?创建单个元素的列表 Collections.singletonList() 也可以吧- if条件代码冗余
if(a&&b){
return true;
}
if(b&&c){
return true;
}- VO 有定义的必要吗? 最高的原则是 PO 能直接返回的不需要转换成 VO
- 创建的 cache 是本地缓存,请问现场部署双节点,添加或删除操作只能是一个节点处理,另一个节点如何刷新? 不用启动就装载吧,使用后缓存也挺香的吧?
//请注意这里,需要转换为List做保存
List<String> xx = JSON.parseArray(item.getxx(), String.class);
// 前端也需要特意处理 xx.js
item.xx = JSON.parse(item.xx);- 上述代码中需要手动转换的,可以使用@Convert 注解完成转换,对业务逻辑代码没有侵入,前端后端无需强制转换。
@Convert(converter = StringToListConverter.class) - 枚举类不要提供set方法 枚举类是jdk的一个语法糖,其本质是通过普通类实现的,只是编译器为我们进行了加工处理,每个枚举类型编译后的字节码实质都是继承自Java.lang.enum的枚举类型同名普通类,而每个枚举常量实质上是一个枚举类型同名普通类的静态常量对象,所有枚举常量都是通过静态代码块进行初始化实例赋值。 当用set方法进行赋值的时候,实际上是修改的一个内存中的静态变量的值,这个值原本的意义就被修改了,这时候如果其他地方再来判断,必然出错。
controller可设置全局异常捕获统一处理, ``@ControllerAdvice @ExceptionHandler`- VO一般用于页面, 数据传输应使用DTO( 其实实例名都是对的 )
- xx 没有
override toString方法, 直接通过log.error打印是看不到参数的 - 包内部不对外的实现类不要用
public避免了到处乱引用的问题 - 该提取为工具类的要提取出来 与业务没有关系, 尽量不在service里面维护, 工具类该提还是得提
- 查库之前集合判空, 避免sql异常
- 实现类命名需要加上Impl区分
Post Views: 339
边栏推荐
- There is no picture problem when using tcpdf to generate pdf
- Webrtc audio and video development - experience
- QT 一个控件的坐标怎么相对固定显示在另一个控件上(坐标系)
- Pat 1054 the dominiant color (20 points)
- How to make up the PMP Exam? How much is the make-up exam?
- 数据库基础笔记
- 10、标准I/O输入输出重定向及管道
- 華為雲的AI深潜之旅
- Axure custom components
- Activate function
猜你喜欢

Adding a markdown editor to lavel

别再问我,UI自动化测试怎么做了……

What is an interface? What is interface testing?

Appium automated test Jiugongge unlock

E-commerce is popular, how to improve the store conversion rate?

If you are a C developer, look at these three explicit programming techniques

项目管理到底管的是什么?

IDC:阿里云获2021中国数据治理平台市场份额第一

Multinomial distribution (a discrete distribution)
![[webapi] return dynamic list dynamic](/img/83/b0b36ddab6d74ccd89811cbb58d051.jpg)
[webapi] return dynamic list dynamic
随机推荐
Real time transformer: meituan's research on single image depth estimation
F1tenth gym of ROS 2 humble hawksbill
#yyds干货盘点# 解决剑指offer: 连续子数组的最大和(二)
Icon fill color and background color change together
Usage example of qjsonobject
Pat 1024 palindromic number (25 points) sum of large integers
2022年股票在手机上开户安全吗?找谁可以办理?
Comprehensive evaluation of easy-to-use and powerful PDF reading software: PDF expert, marginnote, liquidtext, notability, goodnotes, Zotero
E-commerce is popular, how to improve the store conversion rate?
Native implementation Net 5.0+ custom log
17 `bs对象.节点名h3.parent` parents 获取父节点 祖先节点
零基础自学SQL课程 | SQL中的日期函数大全
Nc1033 palindrome substring of small a (ring, interval DP)
ADB regular use of work notes
Smarca2 antibody study: abnova smarca2 monoclonal antibody protocol
Multinomial distribution (a discrete distribution)
Architecture design of e-commerce secsha system
视觉弱监督学习研究进展
How can the sports app keep the end-to-side background alive to make the sports record more complete?
Openfire user and group relationship migration