当前位置:网站首页>code review
code review
2022-06-28 22:16:00 【Yuyy】
This paper is finally updated at 781 Days ago, , The information may have developed or changed .
new Date(xx.getTime() + 5 * 1000)Time operation , Please use calendar class or java 8 Time class of , Reduce redundancy new Date objects creatingArrays.asList(xx).stream()Take a look for yourself Arrays.asList() The source code. ,Arrays.stream(new Object[]{spVO}) Is it not fragrant ? Create a list of individual elements Collections.singletonList() It's OK- if Condition code redundancy
if(a&&b){
return true;
}
if(b&&c){
return true;
}- VO Is it necessary to define ? The highest principle is PO Those that can be returned directly do not need to be converted into VO
- Created cache It's local cache , Could you tell me about the two nodes of on-site deployment , Add or delete operations can only be handled by one node , How to refresh another node ? Load without startup , The cache after use is also very fragrant ?
// Please pay attention here , Need to be converted to List Do preservation
List<String> xx = JSON.parseArray(item.getxx(), String.class);
// The front end also needs to be specially handled xx.js
item.xx = JSON.parse(item.xx);- The above code needs to be manually converted , have access to @Convert Annotation complete conversion , No intrusion into business logic code , The front end and back end do not need to be forced .
@Convert(converter = StringToListConverter.class) - Enumeration classes do not provide set Method Enumeration class is jdk A grammar sugar of , Its essence is realized through ordinary classes , Only the compiler has processed for us , The compiled bytecode of each enumeration type is essentially inherited from Java.lang.enum Enum type of the same name ordinary class , Each enumeration constant is essentially a static constant object of a common class with the same name as the enumeration type , All enumeration constants are assigned to initialization instances through static code blocks . When used set Method for assignment , In fact, it is to modify the value of a static variable in memory , The original meaning of this value has been modified , At this time, if other places judge again , Inevitable error .
controllerYou can set global exception capture unified processing , ``@ControllerAdvice @ExceptionHandler`- VO Generally used for page , Data transmission shall use DTO( In fact, the instance names are all right )
- xx No,
override toStringMethod , Directly through log.error You can't see the parameters when printing - The implementation classes inside the package but not outside the package should not be used
publicAvoid the problem of quoting everywhere - The extracted tool class needs to be extracted It has nothing to do with business , Try not to be in service Internal maintenance , Tools should be mentioned or should be mentioned
- The collection will be judged empty before the database search , avoid sql abnormal
- To implement class naming, you need to add Impl distinguish
Post Views: 339
边栏推荐
猜你喜欢

初识阿里云(云计算)—发展历程和技术架构、地域和可用区!

零基础自学SQL课程 | SQL中的日期函数大全

ADB regular use of work notes

Zadig 面向开发者的自测联调子环境技术方案详解

ROS 2 Humble Hawksbill 之 f1tenth gym
![[golang] leetcode intermediate subset & Word Search](/img/3a/f63892160c25196335a633424c6d99.jpg)
[golang] leetcode intermediate subset & Word Search

Use of axurer9 option group

城市大脑知识图谱构建及应用研究
![[width first search note] BFS output shortest path](/img/b5/553ca241ae571daecabd282f33f20a.jpg)
[width first search note] BFS output shortest path

Rosdep update using fishros to solve ros1/ros2 problems 2022
随机推荐
Akamai acquires linode
Hardware development notes (VII): basic process of hardware development, making a USB to RS232 module (VI): creating 0603 package and associating principle graphic devices
ansible生产环境使用场景(七):批量部署elk客户端
CVPR 2022|极具创意&美感的文字生成方法!支持任意输入
安全 创新 实践|海泰方圆受邀参加“数字时代的网信创新与价值共创”技术交流研讨会
Zero foundation self-study SQL course | complete collection of date functions in SQL
职场人调研报告:裸辞占比最高的居然是中年人
Rule engine development experience sharing - reddit
【SSH】无密码登录
Introduction to wrk pressure test tool
终于有人把云原生架构讲明白了
硬件开发笔记(七): 硬件开发基本流程,制作一个USB转RS232的模块(六):创建0603封装并关联原理图元器件
职场进阶 | 了解岗位优势三板斧之“进场”
Yiming Anke submitted a statement to the Hong Kong Stock Exchange: the loss doubled in 2021, and the past financing amount was exaggerated
PAT 1021. Traversal of the deep root (25 points) graph, DFS, calculating the number of connected components
PHP自学Go日记(四):GO的变量声明方式
Sword finger offer:[day 1 stack and queue (simple)] --- > stack containing min function
宜明昂科在港交所递表:2021年亏损翻倍,过往融资额存在夸大情形
There is no picture problem when using tcpdf to generate pdf
Is it safe to open a stock trading account? Is it reliable?