当前位置:网站首页>(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 !
边栏推荐
- 2022-06-30 unity core 8 - model import
- Simulation volume leetcode [general] 1706 Where does the ball meet
- DRF defines views and routes
- Jenkins+ant+jmeter use
- Selenium mouse sliding operation event
- [chaosblade: node disk filling, killing the specified process on the node, suspending the specified process on the node]
- C language pointer (Part 1)
- 华为HCIP-DATACOM-Core_03day
- Jenkins modifies the system time
- When inputting an expression in the input box, an error is reported: incorrect string value:'\xf0\x9f... ' for column 'XXX' at row 1
猜你喜欢

H3C VXLAN配置

Mysql数据库-锁-学习笔记

Why is access to the external network prohibited for internal services of the company?

MySQL master-slave delay solution

External interrupt to realize key experiment

Systick tick timer

Panel display technology: LCD and OLED

Druid monitoring - Introduction to JMX usage and principle

Pycharm importing third-party libraries

Jenkins modifies the system time
随机推荐
Mysql数据库-锁-学习笔记
2022-06-30 unity core 8 - model import
端口复用和重映像
Cmake command line use
Systick tick timer
Storage of data in memory
C language pointer (Part 2)
Register address name mapping
Interview question: general layout and wiring principles of high-speed PCB
Reflections on the way of enterprise IT architecture transformation (Alibaba's China Taiwan strategic thought and architecture practice)
OpenGL frame buffer
PMP examination experience sharing
OpenGL 3D graphics rendering
Pytest installation (command line installation)
串口實驗——簡單數據收發
Sublime Text4 download the view in bower and set the shortcut key
Jenkins task grouping
[chaosblade: node disk filling, killing the specified process on the node, suspending the specified process on the node]
C language pointer (Part 1)
External interrupt to realize key experiment