当前位置:网站首页>(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 !
边栏推荐
- Simulation volume leetcode [general] 1705 The maximum number of apples to eat
- 【云原生】DevOps(一):DevOps介绍及Code工具使用
- Record of structured interview
- 寄存器地址名映射
- MySql数据库-索引-学习笔记
- RuntimeError: Calculated padded input size per channel: (1 x 1). Kernel size: (5 x 5). Kernel size c
- Hard core sharing: a common toolkit for hardware engineers
- How can I apply for a PMP certificate?
- Port multiplexing and re imaging
- How to use Arthas to view class variable values
猜你喜欢

Postman interface test (I. installation and use)

Screen automatically generates database documents

Hard core sharing: a common toolkit for hardware engineers

C language pointer (exercises)

Summary of PMP learning materials

Connecting mobile phone with ADB

Unityshader introduction essentials personal summary -- Basic chapter (I)

Druid monitoring - Introduction to JMX usage and principle

C language pointer (Part 2)

MySQL master-slave delay solution
随机推荐
Zen - batch import test cases
Variable parameter of variable length function
Simulation volume leetcode [general] 1706 Where does the ball meet
Yapi test plug-in -- cross request
Jenkins task grouping
C语言指针(下篇)
STM32的时钟系统
C语言指针(中篇)
Cesium does not support 4490 problem solution and cesium modified source code packaging scheme
Regularly modify the system time of the computer
C语言指针(习题篇)
How to use Arthas to view class variable values
NVIC中断优先级管理
Skill review of test engineer before interview
Unittest simple project
Count the number of words C language
C语言指针(上篇)
LeetCode每日一题(2316. Count Unreachable Pairs of Nodes in an Undirected Graph)
Locust performance test 4 (custom load Policy)
How can I apply for a PMP certificate?