The code review serves as the powerful new characteristics of JBuilder 2005, and directs the soft ribs in the encoding, and strives to kill the errors in the encoding in germination, and force the company's coding quality.
JBuilder 2005 According to Sun's code specification and software development communities, Java is summarized in Java-developed coding style, statement, Javadoc document annotation, EJB specification, naming style, potential error, encoding. The code review and give a warning such as the Snake Adventures, so that developers have found these shortcomings and hidden dangers.
Code review and syntax error check is two different levels of concept. The syntax error is a low-level, mandatory check, and any programs that violate the grammar cannot be compiled, which means that the runable program must be correct. The code review is a high-level, non-mandatory inspection, which imparts more stringent requirements for the correct procedures of grammar, thereby enhancing the readability of the program, reducing the incompleteness of the variable naming, method definition, program logic. Increase the potential error rate of the program, increase the maintenanceability and robustness of the program.
Lin Lin's Java programming standard, programming paradigm, and programming experience are committed to improving code quality, program performance, software maintenance, etc., JBuilder 2005 code review is the effective programming, paradigm, and experience of various functions. Applying to your program so that your procedures comply with these proven programs that have been largely practiced are successful.
JBuilder 2005 The code review mechanism set up in the default is Sun's code programming specification, which provides a large number of optional review rules, you can activate or close the rules of these reviews as needed.
For beginners, the code review is undoubtedly a good teacher who is learning and working, and JBULDER 2005 has reached the role of "supervising and improving the development staff through instant code review." Developers can also learn more programming requirements and experience outside the grammar through code review.
Read navigation
First, use code review
By default, JBuilde 2005 does not activate the functionality of the code review, you can call the code review page via Project-> Project Properties ...-> Code Audits calls the code review page.
Second, the code style review
Often some programmers are keen to play the Java's grammar to the excellent credentials for Java syntax. However, in a software project that needs to be fully collaborative, it is clear, and it will be clear and easy to understand will be highly respected, and the obscurity and understanding will be degraded. Therefore, most of the software companies' norms have made a requirement of the statement. The JBuilder 2005 code review can help companies implement and implement this requirement to a certain extent.
Third, statement review
The membership variables and local variables are hidden, often make developers to League Li Dai, make some unhappy mistakes, and the members and static variables of the child hidden parent are often caused by the same names already have the same name in the parent class. The program BUG produced by this is difficult due to its stealth, and JBuilder 2005 provides several tools for reviewing the declaration.
Fourth, naming style
Good naming style is complied with the Java naming syntax, and the naming style must comply with Java naming rules.
V. Potential error review
Due to the specificity of the process control statement syntax, special attention is required when writing programs, otherwise it will be buried, and JBuilder reviews these statements from multiple aspects.
6. Avoid all kinds of painted snakes
The power of the JBuilder 2005 code review feature is also able to judge that excess IMPORT packets are introduced, unnecessary mandatory type conversions, unwanted members, excess interface modifiers, etc.
Seven, other
In the program, there is an invalid expression due to various reasons, or the program that can never use, for these useless code, the code review feature provided by JBuilder 2005 can also be found and remind the programmer.
to sum up
JBuilder 2005 provides code review capabilities above the grammar, not only enhances the simpleness, readability of the program code, but also finds a potential coding error as soon as possible, preventing problems. The JBuilder 2005 code review feature is undoubtedly a groundbreaking job, which will have a profound impact on program development and a development direction of intelligent development tools.
Using JBuilder 2005 Code Review By default, JBuilde 2005 does not activate the code review feature, you can call the code review page via Project-> Project Properties ...-> Code Audits calls the code review page, as shown in Figure 1:
Graph code review setting
Check "Enable Code Audits" in the Code Audits Settings page to activate the code review feature of the current project. The left side of the Code Audits Settings page is a tree of a code review rule item. It is divided into two levels. The first level is the classification of the review rule item, and the first level of the node, the second level is a specific one. Rule items can be checked as needed to cancel the rules that can be canceled.
Click the rule item, display the detailed description of this rule in the right side of the Code Audits Settings page and provide an instance to facilitate developer learning and understanding.
After activating the code review rules, JBuilder 2005 reviews the program files written in the editor in real time and labeled in the control tank near the review rule code.
The critical point of violation of rule code will be identified with a pink downward wavy line, in addition, listed all the current procedures all violates the code of the review rule under the WARNING folder of the structural pane, as shown in Figure 2:
Figure Structure Pane in the code review result summary
The review results describe the brief description of the problems in the code, through this prompt and compiler control tank
When the logo, click the review result item, the corresponding code content in the editor will display the following dashed lines. By viewing the corresponding code, the developer will quickly find the problem. After correcting the problem, the corresponding review warning will automatically clear from the Warning folder.
Code style review
1. "Switch" must bring a default statement
Based on Sun's encoding specification, each Switch process control statement must take a default branch to ensure logical branch integrity. By default, the review entry is not activated, the corresponding setting item is "'Switch' Statement Should Include A Default Case" under "Coding Style".
Code List 1 All Switch must take Default branch
1. Switch (FormatType) 2. {3. Case 1: 4. Formatstr = "YYYYMMDDHHMMMMS"; 5. Break; 6. Case 2: 7. Formatstr = "YYYY '-' mm '-' DD HH: mm: SS "; 8. Break; 9. Case 3:10. Formatstr =" YYYY.MM.DD HH: mm: SS "; 11. Break; 12. Case 4:13. Formatstr =" YYYY 'year' mm 'month' DD HH: MM: SS "; 14. Break; 15. Default: 16. Formatstr =" YYYY '-' MM '-' DD HH: mm: SS "; 17.
If there is no DEFAULT code in the 15th to 16th line, the code review will give a warning.
prompt:
The Switch Process Control Statement Code block that can be invoked by Ctrl J calls the Switch Code The code block will take a default branch, not only accelerating the encoded entry efficiency, also guarantees the code block normative. 2, static members should be referenced by class name
All static methods or variables in the class should be referenced by class name. If these static members will affect the readability of the program if instances of the class will affect the readability of the program. If a static variable is referenced by class name, it will easily distinguish between these members' static properties. Because the static member variables exist only in the JVM, rather than each object instance, so static member variables can view members.
Code List 2 About static members
PUBLIC CLASS ASMO12. {3. Void Func () 4. {5. ASMO1 OBJ1 = New asmo1 (); 6. Asmo2 Obj2 = New asmo2 (); 7. Obj1.attr = 10; // Corrected as ASMO1 .attr8. Obj2.attr = 20; // should be ASMO2.attr9. Obj1.Oper (); // should be ASMO1. Oper (); 10. Obj2. ga. OPER (); // should be ASMO2. Oper (); 11. this.attr ; // should be ASMO2. Attr ; 12. THIS.Oper (); // should be ASMO2 OPER (); 13.} 14. 15. static int attr; 16. Static void Oper () 17. {} 18.} 19. 20. Class asmo221. {22. static int attr; 23. static void Oper () 24. {} 25.
The set item corresponding to the review rule is "Accessing Static Members By The Descend Class Name" under "Coding Style".
3. Avoid complex codes
Often some programmers are keen to play the Java's grammar to the excellent credentials for Java syntax. If it is to practice syntax, understand the syntax, it is uncomfortable. However, if you need to fully cooperate with the software project, it is clear, it will be clear and easy to understand will be highly respected.
Therefore, most of the software companies have made a requirement for the sint of statement. The JBuilder 2005 code review can help companies implement and implement this requirement to a certain extent.
Code List 3 demonstrates the 语 语 语 写 写 写:
Code List 3 Complex 涩 语 语
1. INT i = 0; 2. INT j = 0; 3. INT k = 0; 4. INT L = 0; 5. i * = J; 6. / / Should be changed to: 7. // J; 8. // i * = j; 9. 10. k = j = 10; 11. // should be changed to: 12. // k = 10; 13. // j = 10; 14. 15. L = J = 15; 16. // should be changed to: 17. // j = 15; 18. // L = J; 19. 20. i = j 20; 21. // should be changed to: 22. // i = j 20; 23. // J ; 24. 25. i = (j = 25) 30; 26. // should be changed to: 27. // j = 25; 28. // i = j 30; 29. 30. i = j 20; 31. // should be changed to: 32. // i = j 20; 33. // j ; 34. 35. i = (j = 25 ) 30; 36. // should be changed to: 37. // j = 25; 38. // i = j 30; JBuilder 2005 does not activate the review of complex assignment statements in the initial state, the review content corresponds to "COMPLEX Assignment" setting item under Coding Style.
In addition to paying attention to assignment statements, due to the high flexibility of the FOR loop control statement, the code in for () is often a paradise of complex code, and the value-separated assignment statement should not exceed 3 in a comma-separated assignment statement:
Code list 4 Complex for statement
1. for (i = 0, j = 0, k = 10, l = -1; i <10; i , j , k -, l = 2) 2. {3. // do something4.} 5 // Should be changed to the following style 6. // l = -1; 7. // for (i = 0, j = 0, k = 10; i The review content corresponds to the "COMPLEX INITISATION" setting item under "Coding Style". 4, try to use the assignment operator Using assigning operations (=, / =,% =, =, >> =, & =, ^ =, >>> =, & =, ^ =, and | =, The statement can improve the speed of the encoding, enhance the simpleness of the code, and assign the operator to make some editors run faster. Code Listing 5 Using assignment operation 1. void Oper () {2. INT i = 0; 3. i = i 20; 4. I = 30 * i; 5.} 6. // Should be changed to 7. // void Oper () 8. // {9. // int I = 0; 10. // i = 20; 11. // i * = 30; 12. //} This review content corresponds to "Use Abbreviated Assignment Operator" under Coding Style " "Settings. 5. Review of other code style 1) Write multiple lines of statements in the same row code. The review content corresponds to the "MultiPle Statements On One Line" setting under Coding Style. 2) The code block should be framed in the "{}", although the code is increased, but the code structure is stronger. The review content corresponds to the "Place Statement In Block" setting item under Coding Style. 3) Declaration of "L" using uppercase, rather than lowercase "L", because the latter and number 1 are similar. The review content corresponds to the "Coding Style" setting item. Code Listing 6 illustrates the above review item: Code List 6 Other Code Style Review 1. i ; 2. J ; 3. // should be changed to 4. // i ; 5. // J ; 6. 7. if (Val <0) 8. Return; 9. While (VAL> = 10) 10. VAL / = 10; 11. // should be changed to 12. // IF (Val <0) 13. // {14. // Return; 15. //} 16. // While (VAL> = 10 17. // {18. // VAL / = 10; 19. //} 20. 21. Void Func () {22. long var = 0x0001111L; 23.} 24. // Change to 25. Void func () {26. long var = 0x0001111L; 27. In addition, JBuilder 2005 also provides a number of code-style review items, and readers need to depart according to actual needs. Statement review 1 to avoid naming overlays Name hidden review has the following cases: 1) The class member variable is hidden by local variables: the local variables and class member variables in the class method have the same name, and the member variable is shielded. Under normal circumstances, the member variables in the incubation parameters of the class constructor or assignment method maintain the same name, and the member variable of the class is explicitly identified by this case, and the review rule will not be alert. The review content corresponds to the "Hiding Names" setting item under "Declaration Style". Code Listing 7 Local variable hidden member variables 1. Public class hidename2. {3. int index; 4. Void func () 5. {6. int index; // Hide a member variable index, it should be changed to another name, such as int newIndex; 7. // do Something8.} 9. void setIndex 10. {11.iddex = index; // This statement line with this explicit reference member variable for assignment, the review rules will not be alarm 12. Index ; // The statement line does not have this explicit reference. The review rules will be alarm 13.} 14.} 2) Sub-class member variables hide the parent class member variable: Sub-class member variables and the inherited parent class member variable name. The review content corresponds to the "HIDING Inherited Field" setting item under "Declaration Style". Code List 8 Sub-class member variable hides the parent class member variable 1. Class window2. {3. protected int style; 4.} 5. 6. Class Button Extends WINDOW7. {8. protected int style; // Have the same member variable as the parent class, should be changed to another name, such as AnStyle9.} 3) Subclass covers the parent class static method: and non-static methods are not the same, static parent class methods should not be covered by subclasses, which corresponds to "Hiding Inherited Static Methods" under "Declaration Style". Code list 9 subclasses overwriting parent class static methods 1. Class Animal2. {3. Static void Oper1 () {} 4. Static void Oper2 () {} 5.} 6. 7. Class ELEPHANT EXTENDS ANIMAL8. {9. static void Oper1 () {} // Hide The static method in the parent class should take another name, such as Anoper1 () 10. Static void Oper2 () {} // hide the static method in the parent class, should take another name, such as Anoper2 () 11. The membership variables and local variables are hidden, often make developers to League Li Dai, make some unhappy mistakes, and the members and static variables of the child hidden parent are often caused by the same names already have the same name in the parent class. The resulting program BUG is difficult to discover due to its hike, this review will help you avoid this problem. 2, use suitable modifiers Static, Final, visual field oriented modifiers can be used to modify, class members variables, methods, and internal classes, using the appropriate modifiers, classes, and relaxation will be enhanced while also preventing erroneous calls. The review of modifiers mainly includes the following 3 points: 1) The constant should be identified as final: This can prevent the program from changing its value or prevent the coverage of the subclass. The review content corresponds to the "Constant Variables Should Be Final" setting item under "Declaration style". 2) Not being called by the external call should be declared as Private: The review item is to investigate the encapsulation and cohesiveness of the class, so that the interface corresponding to the class is more clear. The review item does not take effect on the members of Public, and the member identified as public will be seen as an open. The review content corresponds to the "MEMBER CAN BE MADE Private" setting item under Declaration Style. When receiving the alarm of the review, developers need to make judgments according to the actual situation to make it indeed set to private members to correct. 3) Members set to Static: JBuilde R2005 Analysis which member variables and members of the members can be set to Static: those who use the member variables used in static environments and the internal classes without reference container non-static members and methods. The review content corresponds to the "MEMBER CAN Be Made Static" setting item under Declaration Style. 3. Review of subclass coverage JBuilder will review the following aspects in inheritance coverage: 1) Equals () and havehcode () methods must be overwritten at the same time: Class overwrite the equals (Object Obj) defined in the Object class, and must also override the HashCode () method defined in the Object class, as you must guarantee Equals ( Object obj) Judging the same object of the same HashCode value. The review content corresponds to the "Override Hash Code When You Override Equals" setting under "Declaration style". 2) Cover the non-abstract classes in the parent class into an abstract class: there is no reason to cover the abstract class of the parent class to the abstract class of the subclass, and even it can be concluded that this is the bias on the encoding. The review content corresponds to the "Overriding A Non-Abstract Method With An Abstract Method" setting item under "Declaration Style". 3) Declaration and parent class in subclasses and parent class: The private method is not covered, in general, the method of being covered by the subclass is Protected or public. The review content corresponds to the "Overriding a Private Method" setting item under "Declaration Style". 4, code arrangement and success Good organization for the code of the class file, enhance the user-maintainability and readability of the code, JBuilder 2005's arrangement of the code and the following review: 1) Arrangement of class members: According to Sun's code programming conventions, members' ahead sequences from large to small arrangements, namely: public-> protected-> Default -> private. Members in the class are arranged as follows: 2) Static member variables are ranked to the front, and static members are arranged from large to small. 3) The second bit is an instance member variable, and an instance member variable is arranged from large to a small. 4) The third is the constructor. 5) The fourth place is a member method The review content corresponds to the "ORDER OF Declaration of Class Members" settings under "Declaration style". i Lein the overload method: The overload method of the class completes similar functions, with the same method name, which can enhance the readability of the program, and it is not easy to miss a feature. The review content corresponds to the "Place Methods With Same Name TOGETHER" setting under "Declaration Style". II puts the public class in front: For program files with multiple classes, PUBLIC's class should be placed in front. The review content corresponds to the "Place Public Class First" setting item under "Declaration Style". Named style 1, cancel bad name habits Good naming style is complied with the Java name syntax, and the naming style must comply with the following naming rules: 1) The class or interface must be headed by uppercase letters. 2) Method, attribute, member variable, local variable heads with lowercase letters, and do not head with "_" or "$". 3) All letters of constants are capitalized. 4) The anomaly class is at the end of Exception. Good naming corresponding to the "Naming Conventions" setting item under "Naming Style". 2, establish and internationally launched bag name The name should be headed by top-level domain, such as COM, ORG, EDU, etc., or with national code such as CN, RU, etc. General companies and organizations have strict rules at the top two levels, such as IBM's classes taken with com.ibm, Apache heads with org.apache, the third level is specific project or product name, such a package name As the URL naming like a three-dimensional network has become an international general guideline. For companies that have not made strictly specified, the development person in charge should promote the establishment of specifications that meet this naming rule. This review item, by default, it is not activated, and can be activated by the "package" setting item under "Naming Style". 3. Avoid using too simple variable names In addition to the temporary variables in the cyclic body, and some common data types that do not make special sense should try to avoid using a character as a variable. Those single-character variable names selected without special meaning and common, must be naming according to Table 1: Table 1 Variable itself is meaningful in common data type allowed single-character variables Common data type single-character variable name Common data type single character variable name Byteb Double Dchar C Objectoint I, J, KStringslonglexceptionefloat F In addition, in order to reduce potential conflicts, avoid unnecessary confusion, do not allow variable names in uppercase domain names or national code. Code List 10 Take a meaningful variable name 1. Void method (double d) 2. {3. INT i; 4. Exception E; 5. CHAR S; / / should be changed to c6. Object f; // should be changed to O7. String K; // should be changed For the S8. Object UK; // and the British country code, it should be changed to other names, such as ukobj9. Object COM; // and domain names, should be changed to other names, such as OBJ_110. This review term is not activated by default, and can be activated by the setting item of "Use Conventional Variable Names" under "Naming Style". Potential error review 1, focus switch Due to the special nature of the Switch process control statement syntax, special attention is required when writing programs, otherwise the root will be buried, and JBuilder reviews Switch from the following three aspects: 1) There is no Case Sentence to the front no BREAK statement: According to the Sun encoding practice, the program entry point is entered from one case, directly reaches the next case code segment, that is, when the previous case does not have a corresponding BREAK statement, crossing The place where a display is given, indicating that it is a specific process control, not unintentional. Look at the following code: Code Listing 11 No Break Case clause 1. Switch (c) {2. Case ' ': 3. ... 4. Break; 5. Case '-': 6. ... 7. Case 'N': 8. ... 9. Case '': Case '/ T': 10. ... 11. Break; 12. Assuming that before the 7th line of the code list 11, it is because of the negligence, it is missing a BREAK statement. Before the 9th line is logical needs and deliberately do not add the BREAK statement, then change the code to: Code List 12 Corrected Switch Code 1. Switch (c) {2. Case ' ': 3. ... 4. Break; 5. Case '-': 6. ... 7. Break; 8. Case 'N': 9. .. .10. // Continue to run to below 11. Case '': Case '/ T': 12. ... 13. Break; 14.} The review content corresponds to the "Break Statement IS Missing Before Case Clause" setting item under "Possible ErrorS". 2) A non-case label appears in Switch: There are two labels in the Java statement, the CASE branch tab, the other is a statement tag, if the Case branch label statement misses or misses the case keyword, then the Case branch tag Will be a statement tag, and the compiler cannot identify this error. Code Listing 13 Case branch lacks case to make the label change 1. Public class caselabel2. {3. / ** Point * / 4. Public static final int point = 1; 5. / ** Line * / 6. Public static final int line = 2; 7. / ** polygon * / 8. Public static final int po materialgon = 3; 9. 10. Public string getfigureType (int Kind) 11. {12. String TempName = NULL; 13. Switch (kind) 14. {15. Case Point: 16. Line: / / This statement lacks case, the compiler is handled as a statement tag, and the syntax error is not 17. // However, when the method passes constant LINE, it will go to the default branch, not to reach this morning, so 18 / / The row statement should be changed to Case line: 19. TempName = "Point and line"; 20. Break; 21. Case Polygon: 22. TempName = "Polygon"; 23. Break; 24. Default: 25. TempName = "undefine"; 26.} 27. Return TempName; 28.} 29. The review content corresponds to the "Non-Case Label In Switch Statement" setting item under "Possible Errors". 3) Break and Continue: Break and Continue: Break and Continue are used in Switch and cycles, Break is used to end the cycle in advance and exit from Switch, this "polymorphism" of Break makes it in the cyclic body The embedded Switch statement often brings some hidden dangers. That is, developers want to exit the outer cycle, but only exit the Switch statement of the inner layer. JBuilder 2005 reviews for this content include the following: Switch is embedded in the cyclic body, and the CASE clause contains a BREAK statement that is not located in the last position of the branch block. Switch is embedded in the cyclic body, and the CASE clause uses Break, but uses Continue, but the effect is the same. Unnecessary statement tags are used in the BREAK or Continue statement. Please see the following code: Code list 14 has error suspicion of Break and Continue Void scan (char [] arr) 2. {3. loop: 4. For (int i = 0; i The review content corresponds to the "Suspicious Break / Continue" setting item under "Possible Errors". 2. Avoid determining the floating point value Floating point numbers are data that is accurate, due to the internal representation of the error, the same two floating point numbers are used, and their internal representation is not exactly the same. Therefore, it should be avoided to be equivalent logic judgment on the number of floating point values, but the logic comparison is used. Code Listing 15 statement contains floating point equivalent judgment 1. Void Calc (Double Limit) 2. {3. IF (Limit == 0.0) / / should be changed to the comparison of the smaller value, such as if (Math.Abs (Limit) <0.000000001) 4. {5 "System.out.println (" The Float-Point Number IS Exactly 0); 6.} 7. The review content defaults to activate the review by the "Suspicious Break / Continue" setting item under "Possible Erroors". 3. Adding () clearing complex expression write complex expressions should not over-rely on calculation priority, and should develop a good habit of "()", when a logical expression is made of multiple When the logical operation is composed, "()" should be used to divide different parts. Code list 16 Clear expression of brackets 1. Boolean A, B, C; 2. ... 3. If (a || b && c) / / should be replaced into IF ((a | | b) && c) 4. {5. ... 6 } The review content defaults to activate the review by the "Mixing Logical Operators WITHOUT PARENTHESES" setting item under "Possible ErrorS". 4, string comparison A common mistake of Java beginners is to use "==" or "! =" To perform equivalence logic judgment on the string. Using "==" will determine whether both of them point to the same object reference, rather than judging whether or not the two have values, it should be replaced with equals (). Code List 17 with equals () replacement "==" Public Boolean Equals (String S1, String S2) 2. {3. Return S1 == S2; // Should be changed to Return S1.Equals (S2); 4. The review content corresponds to the "Use 'Equals' INSTEAD OF '=='" setting item under "Possible Errors". Avoiding various painted snakes 1, compare Boolean variables and boolean values There is no need to compare the Boolean variables and Boolean values, you should ensure that "TRUE" or "false" does not appear in logical expressions: Code List 18 Avoiding a Boolean Floor value in a logical expression 1. Boolean success = init (); 2. If (Success == true) // should be corrected 3. {4. ... 5. The review content corresponds to the "Equality Operations On Boolean Arguments" setting item under "Superfluous Content". 2, useless member The member method and member variable in the class cannot be called in an external class. If the member variable or method for Private is found to be used in the internal Protect or public method, this member will never be referenced in the running period. And becoming a useless member variable and method. The review mechanism identifies its unused members and alarms. Code List 19 Unexpected Member 1. Public class unuse2. {3. Private string name; 4. Public object value; 5. 6. private object getValue () 7. {8. Return Value; 9.} 10. 11. Private Void Print () 12. {13. System.out.println (GetValue () "=" value); 14.} 15. The Name variables in the code list 19, the getValue () and print () methods are useless methods, because it is not possible to access these members through the outside class, the unuse does not provide the interface to call these members, so these members can be from the class Clear. The review content corresponds to the "MEMBER IS Not Used" setting item under "Superfluous Content". 3, excess interface modifier The interface is abstract, the method defined in the interface is abstract and public, that is, public abstract; the constant in the interface is public static final. So if you use these modifiers when interface definitions, interface member methods, and interface constant declarations, JBuilder 2005 reviews this and reports these excess modifications. Code list 20 Excess interface modifier 1. Interface colors {2. public static final int red = 1; 3. Public Abstract Void getColorname (int color); 4.} The modifier of the bold body in the code list 20 is excessive, and it should be removed. These reviews can be set by "Obsolete Interface Modifiers" and "Unnecessary MEMBER Modifier" review items under "Superfluous Content". 4, unnecessary mandatory type conversion "Small Type" to "Big Type" and sub-class to the parent class automatically type, no need to add an operator for mandatory type conversion, JBuilder 2005 checks these unnecessary type conversions. Code List 21 Unnecessary type conversion 1. Class Animal {} 2. Class ELEPHANT EXTENDS Animal {3. Void Func () {4. INT I; 5. Float f = (float) i; 6. 7. ELEPHANT E1; 8. ELEPHANT E2 = (ELEPHANT) E1; 9. 10. Animal A; 11. ELEPHANT E; 12. A = (animal) E; 13.} 14. The mandatory type conversion statement of the bold bold in the code list 21 is unnecessary, and the mandatory type conversion should be canceled. The review content corresponds to the "Unnecessary Type Cast" review item under "Superfluous Content". 5, excess IMPORT package introduction This review will help you build an optimized import statement segment. When the program file references java.lang. * (Automatic introduction of the compiler), the package where the current class is located, and the unused package or repeated introduction package, JBuilder2005 Will warn. Priority IMPORT Package Introduction The most convenient way is to click the right button in the editor, select the "Format all" menu item in the pop-up menu, and automatically optimize the IMPORT package to introduce the code. You can complete the settings of the optimized package by Project-> Project Properties ...-> java formating-> import code formatting settings. The review content corresponds to the "Import List Construction" review item under "Superfluous Content". other 1, unregulated expression Unregulated expression is in the following two aspects: 1) The comparison expression always returns the same value. Code list 22 expressive value 1. Void Handleevent (EVENT E) {2. IF (e! = Null) {3. ... 4. If (e = = null) {// This expression is always false, because enter this code The E Heng is non-empty 5. ... 6.} 7.} 8. Isletter || Isdigit; // This expression is always True13. ... 14.} 15.} The review content corresponds to "Comparison Always Products the Same Result" under Expressions and "Expression Value Is Constant" Two review items. 2) Invalid arithmetic operation. When the addition and subtraction is performed, one operand is 0. When multiplication is performed, the multiplication or multiplier is 1. When the division is performed, the divisor is 1. When the mold operation is performed, the absolute value of the number of operands on the left is smaller than the absolute value of the number of opens on the right operand, and X% y = X is at this time. When the property assigns a value, the value of itself will be assigned to yourself. Code List 23 Invalid Arithmetic Operation 1. Public class noeffect2. {3. Private string name; 4. Private int index; 5. 6. Noeffect (string n, int index) 7. {8.Name = Name; // Assign the attribute value to itself 9.index = index; 10.} 11. 12. Int getPosition () 13. {14. int base = 0; 15. Return Index base; // and 0 the same 16.} 17. 18. Int getModule () 19. {20. INT x = 1, y = 2; 21. Return X% Y; // The absolute value of the left operands is smaller than the number of operands of the right operand.} The review content corresponds to the "Operation Has No Effect" review item under Expressions. 2, there is an unacceptable statement in the process control Some process controls due to the constant test condition, the program in the process cannot arrive. Code list 24 is not a statement 1. INT [] arr = new int [size]; 2. If (arr == null) // Since Arr is not empty, the test logic is not possible, and the program cannot enter the block 3. {4. Return NULL; 5. The review content corresponds to the "Statement IS Unreachable" review item under BRANCHES AND LOOPS. 3, useless process label The loop is marked with the statement tag, but use this tag anywhere, that is, the label is a useless tag, which should be removed. Code List 25 Useless Process Tags 1. Int FindItem (Object [] list, object item) {2. loop: // No place in the program 3. for (INT i = 0; i The review content corresponds to the "Label IS Not Used" review item under "Branches and Loops". to sum up JBuilder 2005 provides code review capabilities above the grammar, not only enhances the simpleness, readability of the program code, but also finds a potential coding error as soon as possible, preventing problems. The JBuilder 2005 code review feature is undoubtedly a groundbreaking job, which will have a profound impact on program development and a development direction of intelligent development tools.