【原因分析】
在同一个java文件,相同的字符串出现了多次。例如:
public String doAdd(HttpServletRequest request) {
String name = request.getParameter("name");
......
}
public String doUpdate(HttpServletRequest request) {
String newName = request.getParameter("name");
......
}
【影响分析】
重复的代码会增加维护难度,如果字符串内容变更了,则需要同时修改多处。
【修改建议】
将相同的字符串定义成一个常量。例如:
private static final String PARAM_NAME = "name";
public String doAdd(HttpServletRequest request) {
String name = request.getParameter(PARAM_NAME);
......
}
public String doUpdate(HttpServletRequest request) {
String newName = request.getParameter(PARAM_NAME);
......
}
相关推荐
Surround With feature is no longer invokable within comments, string literals, and tags in XML/HTML/XAML. (case=74045) Fix for Visual Studio reporting an exception when scrolling quickly through ...
way to teach computer programming concepts is with multiple examples. Command descriptions, format syntax, and language references are not enough to teach a newcomer a programming language. Only by ...
Multiple Windows and Frames Chapter 14. The Document Object Section 14.1. Document Overview Section 14.2. Dynamically Generated Documents Section 14.3. Document Color Properties Section ...
PEP 498: Formatted string literals PEP 526: Syntax for variable annotations PEP 515: Underscores in Numeric Literals PEP 525: Asynchronous Generators PEP 530: Asynchronous Comprehensions PEP 487:...
7.13 String literals 7.14 Numeric expressions 7.15 Syntax of numeric literals 7.16 Syntax of floating-point literals 7.17 Logical expressions 7.18 Logical literals 7.19 Unary operators 7.20 Binary ...
Suppose if we have a declare an array of type String, then it will store only the String value not any other data type. When we have a closely related data of the same type and scope, it is better to...
produced when this parameter was a null string (""). Now, the original input filename is used as the AML output filename, with an ".aml" extension. Implemented a generic batch command mode for the ...
TypeScript Dedent ... multiple lines. Luckily dedent is here to keep it readable without lots of spaces ending up in the string itself.` ) ; console . log ( dedent ` A string that gets so long y
Accessing Properties Using the Dot Operator 134 Multiple Arguments to Methods 135 Methods Without Argument Names 137 Operations on Fractions 137 Local Variables 140 Method Arguments 141 The static ...
4.5.2 Deriving the Empty String 128 4.5.3 First Sets 130 4.5.4 Follow Sets 134 4.6 Exercises 138 5 Top-Down Parsing 143 5.1 Overview 144 5.2 LL(k) Grammars 145 5.3 Recursive-Descent LL(1) Parsers 149 ...
2.1.4 Literals......... 29 2.1.5 Operators and Punctuators..... . 31 2.2 Input/Output......... . 31 2.3 Program Structure........ . 34 2.3.1 Redirection........ . 36 2.4 Simple Types......... . 37 ...
10.2 String Methods for Pattern Matching 259 10.3 The RegExp Object 261 11. JavaScript Subsets and Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 11.1 ...
5.13 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 6 Basic concepts 39 6.1 Declarations and definitions . . . . . . . . . . . . . . . . . . . ...
2.6 String literals....................................................................................................................................5 2.7 Array literals ...............................
Contents at a Glance Foreword . . . . . . . . ....About the Author ....About the Technical Reviewers ....Acknowledgments....Introduction ....■CHAPTER 1 Introduction ....■CHAPTER 2 Structure of the NetBeans Platform ....
go程序设计语言 Contents Preface................................................................................................................................. xix PART 1—WHY LEARN GO—GETTING ...
2.14 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3 Basic concepts 34 3.1 Declarations and definitions . . . . . . . . . . . . . . . . . . ...
The Way to Go,: A Thorough Introduction to the Go Programming Language 英文书籍,已Cross the wall,从Google获得书中源代码,分享一下。喜欢请购买正版。 目录如下: Contents Preface......................
Literals .................................. 73 Exponential notation ................... 74 Bitwise operators .................. 75 Shift operators ......................76 Ternary if-else operator ......
Table of Contents Introduction....................................................................................................13 Code Examples.........................................................