当前位置:网站首页>(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 !
边栏推荐
- Locust performance test 3 (high concurrency, parameter correlation, assembly point)
- Skill review of test engineer before interview
- Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
- Port occupation troubleshooting
- Simulation volume leetcode [general] 1705 The maximum number of apples to eat
- Pycharm create a new file and add author information
- RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
- How to use Arthas to view class variable values
- Systick滴答定时器
- OpenGL 3D graphics rendering
猜你喜欢
Pytest+request+allure+excel interface automatic construction from 0 to 1 [five nails / flying Book notice]
Port multiplexing and re imaging
How to use Arthas to view class variable values
Led analog and digital dimming
串口實驗——簡單數據收發
Serial port experiment - simple data sending and receiving
Why is access to the external network prohibited for internal services of the company?
C语言指针(特别篇)
Do you have any certificates with high gold content?
串口实验——简单数据收发
随机推荐
【istio简介、架构、组件】
Upgrade Alibaba cloud RDS (relational database service) instance to com mysql. jdbc. exceptions. Troubleshooting of jdbc4.communicationsexception
Reading notes of pyramid principle
JVM 内存结构 详细学习笔记(一)
Unityshader introduction essentials personal summary -- Basic chapter (I)
Synchronized underlying principle, volatile keyword analysis
Count the number of words C language
Chaosblade: introduction to chaos Engineering (I)
Sublime Text4 download the view in bower and set the shortcut key
Count the number of words in the string c language
徽商期货公司评级是多少?开户安全吗?我想开户,可以吗?
Serial port experiment - simple data sending and receiving
Hard core sharing: a common toolkit for hardware engineers
What is the use of PMP certificate?
Postman interface debugging method
Pycharm create a new file and add author information
Self awakening from a 30-year-old female programmer
Locust performance test 5 (analysis)
2022-06-30 unity core 8 - model import
PMP Exam Preparation experience, seek common ground while reserving differences, and successfully pass the exam