The performance of code cleanliness [transfer]

If you have one of the following conditions, you are suffering from code cleanliness disorder. The severity of symptoms can be mild or severe. The mild ones help to write elegant and clean code, and the severe ones go into trouble and do nothing.

  1. For redundant blank lines, semicolons, and unused variables, see delete one by one.
  2. If the tab or space is not aligned, it must be corrected. Except for indentation, it is not allowed to see two consecutive spaces in the code.
  3. When you see that a method in a class has no annotations, you add it involuntarily, whether it makes sense or not.
  4. Misspellings, whether in naming or annotations, must be corrected; inconsistent capitalization must be corrected; punctuation omissions must be filled.
  5. See that the code like if(a==0) must be changed to the form of if(0==a).
  6. All IDE warnings about code must be eliminated, regardless of whether it is practical or not.
  7. When you see a naked number, you must define it as a constant. Even if the meaning of the number is intuitive, you can only accept constant numbers.
  8. To see the non-static public variables, get/set methods must be established.
  9. The shortcut keys that are constantly organized according to the code format, in Eclipse, are constantly CTRL+Shift+F, CTRL+Shift+O, and even CTRL+S constantly.
  10. Once you see more than 3 consecutive if-else judgment branches, you must optimize; similar method calling codes, if they appear consecutively, must be optimized; methods that exceed several lines must be refactored.
  11. The most essential performance is that he likes to read his own code for a long time, and his heart is full of admiration and self-indulgence.

The article is reprinted by myself, from "The Nagging of the Four Fires"

If you have one of the following conditions, you are suffering from code cleanliness disorder. The severity of symptoms can be mild or severe. The mild ones help to write elegant and clean code, and the severe ones go into trouble and do nothing.

  1. For redundant blank lines, semicolons, and unused variables, see delete one by one.
  2. If the tab or space is not aligned, it must be corrected. Except for indentation, it is not allowed to see two consecutive spaces in the code.
  3. When you see that a method in a class has no annotations, you add it involuntarily, whether it makes sense or not.
  4. Misspellings, whether in naming or annotations, must be corrected; inconsistent capitalization must be corrected; punctuation omissions must be filled.
  5. See that the code like if(a==0) must be changed to the form of if(0==a).
  6. All IDE warnings about code must be eliminated, regardless of whether it is practical or not.
  7. When you see a naked number, you must define it as a constant. Even if the meaning of the number is intuitive, you can only accept constant numbers.
  8. To see the non-static public variables, get/set methods must be established.
  9. The shortcut keys that are constantly organized according to the code format, in Eclipse, are constantly CTRL+Shift+F, CTRL+Shift+O, and even CTRL+S constantly.
  10. Once you see more than 3 consecutive if-else judgment branches, you must optimize; similar method calling codes, if they appear consecutively, must be optimized; methods that exceed several lines must be refactored.
  11. The most essential performance is that he likes to read his own code for a long time, and his heart is full of admiration and self-indulgence.

The article is reprinted by myself, from "The Nagging of the Four Fires"

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042117&siteId=291194637