Skip to content

Latest commit

 

History

History
44 lines (42 loc) · 2.8 KB

checklist.md

File metadata and controls

44 lines (42 loc) · 2.8 KB

Common mistakes (jv-salary-info)

Don't begin class or method implementation with empty line.

Remove all redundant empty lines, be careful :)

If you create a formatter, make it a constant field.

If you create a formatter, make it a constant. That will make your code easier to understand. Plus if you use it in several places in your code you will be able to change its value easily with one action(change variable declaration). In other case you need to update value in each place it's being used.

Use LocalDate instead of Date.

Here is some background why you should use it primarily.

Don't create redundant loops. Two is enough.

The more loops you have, the slower your code may get, so try to solve task with minimum amount.

Don't use two-dimension arrays and HashMap(or any other Map).

They may simplify the work for you, but for now you will get more value from solving this task if you complete it without using these data structures. Let's do it manually.

Use StringBuilder.

You have learned in previous topics about different internal structure of String and StringBuilder don't forget to use it on practice. Keep in mind that String concatenation creates many new objects that take up a lot of memory if you use it inside of a loop. Though it's safe to use it outside of a loop, because compiler will replace it with StringBuilder anyway java doc

Use System.lineSeparator

Different OS handle line separators differently. Instead of using \n or \r\n use universal solution - System.lineSeparator().

Remember about informative names of the variables and methods.

Do not use abstract words like string or array as variable name. Do not use one-letter names. The name of the method should make it clear what it does.

  • Bad example:
    String[] arr = new String[]{"Alex", "Bob", "Alice"};
    for (String s : arr) {
        System.out.println(s);
    }
  • Refactored code:
    String[] usernames = new String[]{"Alex", "Bob", "Alice"};
    for (String username : usernames) {
        System.out.println(username);
    }

Any magic numbers should be constants

Your code should be easy to read. Move all hardcoded values to constant fields and give them informative names.

Write informative messages when you commit code or open a PR.

Bad example of commit/PR message: done/fixed/commit/solution/added homework/my solution and other one-word, abstract or random messages.