当前位置:网站首页>(3/8) method parameters of improper use of enumeration (2)
(3/8) method parameters of improper use of enumeration (2)
2022-07-07 09:19:00 【51CTO】
Continue to talk about the use of enumeration . This article illustrates the crap of not enumerating method parameters .
【 On the first code 】
First look at the following methods :
The call to this method in the program :
The following is RefundStsEnum Enumeration class :
【 Refactoring mode 】
In the above method String Variable rfdSts, The corresponding enumeration types are defined in the program RefundStsEnum.
This example is a typical example of improper enumeration . The crux is to set method parameters rfdSts Define a String, This leads to two things :
- Inside the method , Like the first line , When logging , First call enumeration RefundStsEnum Of getBySts(), take rfdSts Stored RefundStsEnum Of sts Convert to enumeration RefundStsEnum, then , Get it desc.
- The parameters passed by calling this method are RefundStsEnum.getSts()
The right way to do it is : Put the method parameters rfdSts Defined as an enumeration type RefundStsEnum, natural , There is no such unhappiness . It will be clear !
边栏推荐
- 徽商期货公司评级是多少?开户安全吗?我想开户,可以吗?
- Expérience de port série - simple réception et réception de données
- How long does the PMP usually need to prepare for the exam in advance?
- Zen - batch import test cases
- C语言指针(下篇)
- What are the suggestions for PMP candidates?
- Detailed learning notes of JVM memory structure (I)
- Pytest+request+allure+excel interface automatic construction from 0 to 1 [familiar with framework structure]
- 【ChaosBlade:节点磁盘填充、杀节点上指定进程、挂起节点上指定进程】
- Systick滴答定时器
猜你喜欢
随机推荐
Data association between two interfaces of postman
Zen - batch import test cases
PMP experience learning and sharing process
C语言指针(下篇)
C language pointer (special article)
Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
[chaosblade: node CPU load, node network delay, node network packet loss, node domain name access exception]
OpenGL frame buffer
JWT certification used in DRF
C语言指针(中篇)
Some pit avoidance guidelines for using Huawei ECS
Yapi test plug-in -- cross request
PMP certificate preparation experience sharing
Three updates to build applications for different types of devices | 2022 i/o key review
Original collection of hardware bear (updated on June 2022)
Entity of cesium data visualization (Part 1)
Leetcode question brushing record (array) combination sum, combination sum II
Original collection of hardware bear (updated on May 2022)
PMP examination experience sharing
Detailed learning notes of JVM memory structure (I)