当前位置:网站首页>(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 !
边栏推荐
- Do you have any certificates with high gold content?
- JVM 垃圾回收 详细学习笔记(二)
- H3C vxlan configuration
- LED模拟与数字调光
- The essence of high availability
- [chaosblade: node CPU load, node network delay, node network packet loss, node domain name access exception]
- 寄存器地址名映射
- 【ChaosBlade:节点磁盘填充、杀节点上指定进程、挂起节点上指定进程】
- UnityShader入门精要个人总结--基础篇(一)
- 串口實驗——簡單數據收發
猜你喜欢
Pytest installation (command line installation)
Two schemes of unit test
Skill review of test engineer before interview
Jmeters use
Jenkins automated email
PMP Exam Preparation experience systematically improve project management knowledge through learning
MySql数据库-事务-学习笔记
数据在内存中的存储
JVM 内存结构 详细学习笔记(一)
C language pointer (Part 2)
随机推荐
Postman interface test (II. Set global variables \ sets)
C language pointer (special article)
Mysql database index study notes
C language pointer (Part 1)
Count the number of words C language
Simulation volume leetcode [general] 1609 Parity tree
PMP Exam Preparation experience systematically improve project management knowledge through learning
OpenGL frame buffer
LeetCode每日一题(2316. Count Unreachable Pairs of Nodes in an Undirected Graph)
Pycharm create a new file and add author information
PMP experience learning and sharing process
STM32 serial port register library function configuration method
2021 year end summary
【ChaosBlade:根据标签删除POD、Pod 域名访问异常场景、Pod 文件系统 I/O 故障场景】
How to count the number of project code lines
Locust performance test 2 (interface request)
PMP Exam details after the release of the new exam outline
C language pointer (Part 2)
When inputting an expression in the input box, an error is reported: incorrect string value:'\xf0\x9f... ' for column 'XXX' at row 1
[istio introduction, architecture, components]