Confirmed users
905
edits
| Line 3: | Line 3: | ||
=== Basic Code Guidelines that need to be followed for positive reviews === | === Basic Code Guidelines that need to be followed for positive reviews === | ||
* All TABs | * All TABs should be replaced by 4 spaces - use the "use spaces" option in your editor to substitute Tab with spaces | ||
* No spaces should be present at the end of a line after ";", "}", "{" or any other line ender | * No spaces should be present at the end of a line after ";", "}", "{" or any other line ender | ||
* Comments should be added in the code to explain what the code does every time you consider that you would have to explain what or why you did things like that | * Comments should be added in the code to explain what the code does every time you consider that you would have to explain what or why you did things like that | ||
* One line comments should use "//". There | * One line comments should use "//". There should always be a space after "//" and the first letter of the comment should be capitalized | ||
e.g. // This is a one line comment | e.g. // This is a one line comment | ||
* Multiple line comments should use the format " /* comment */ ". The same rules of the single line comment apply plus the text should be aligned for the different lines of the comment: | * Multiple line comments should use the format " /* comment */ ". The same rules of the single line comment apply plus the text should be aligned for the different lines of the comment: | ||
| Line 13: | Line 13: | ||
* Long comments should be spread across multiple lines and not left to be autosplit by display formating | * Long comments should be spread across multiple lines and not left to be autosplit by display formating | ||
* Blank lines can be used inside the body of a method and should be used only to separate logically connected blocks of code | * Blank lines can be used inside the body of a method and should be used only to separate logically connected blocks of code | ||
* After each "{" the text should be indented with an | * After each "{" the text should be indented with an additional tab which should be eliminated at the first "}" | ||
first_lvl_of_indentation { | first_lvl_of_indentation { | ||
second_lvl_of_indentation { | second_lvl_of_indentation { | ||
| Line 22: | Line 22: | ||
} | } | ||
We are back at the 1st level of indentation | We are back at the 1st level of indentation | ||
* | * Correct spacing should be kept when writing methods: | ||
e.g. method_name(arg1, arg2, arg3) { | e.g. method_name(arg1, arg2, arg3) { | ||
- no space between the method name and the parameter list, spaces after each "," in the parameter list and a space between the list and "{" | - no space between the method name and the parameter list, spaces after each "," in the parameter list and a space between the list and "{" | ||
| Line 43: | Line 43: | ||
e.g. String1.equals(String2); | e.g. String1.equals(String2); | ||
* If a block of code is used more then 2 times in a class create a method out of it | * If a block of code is used more then 2 times in a class create a method out of it | ||
* If you need to change a parameter received by the method inside it but you don't want to | * If you need to change a parameter received by the method inside it but you don't want to change it globally define the parameter using an "m" before the label | ||
class example { | class example { | ||
int globalVariable; | int globalVariable; | ||
| Line 57: | Line 57: | ||
* Make variables and methods which do not need to be accessed from outside '''private''' | * Make variables and methods which do not need to be accessed from outside '''private''' | ||
* Declare variables that do not change '''final''' | * Declare variables that do not change '''final''' | ||
* Do not hardcode any data. If you need a value | * Do not hardcode any data. If you need a value somewhere declare it as a variable at the beginning of the code - for e.g. URLs, timeouts | ||
* When using timeouts for test reuse the ones declared in BaseTest unless you need different values for the timeout | * When using timeouts for test reuse the ones declared in BaseTest unless you need different values for the timeout | ||
* Clean up the import list after the test is complete and tested by removing any imports that are not used | * Clean up the import list after the test is complete and tested by removing any imports that are not used | ||
* Clean up variables that you end up not using in the test | * Clean up variables that you end up not using in the test | ||
-- | |||
¯ Adrian Tamas | SoftVision | |||
The content of this communication is classified as SoftVision Confidential and Proprietary Information. | |||