diff --git a/README.md b/README.md index 004c744d5..66dcd9aca 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,17 @@ # jv-checked-exception --- -Let's help user to register :) +Let's help the user register :) -We should implement the methods: +We should implement the following methods: - `registerUser()` in UserService class - `validate()` in PasswordValidator class -Method `validate()` should compare the `password` with `repeatPassword` and check -if their length is more or equal to 10. If not, throw exception `PasswordValidationException` -with message "Wrong passwords" (since it's our custom logic, let's create our own, **CHECKED**, exception -because user can put any password and our service shouldn't be broken. We should handle not-valid case and return the understandable message). +Method `validate()` should compare the `password` field with the `repeatPassword` field and check if their length is more or equal to 10. If not, throw exception `PasswordValidationException` with the message "Wrong passwords" (since it's our custom logic, let's create our own, **CHECKED**, exception because the user can put any password and our service shouldn't be broken. We should handle the not-valid case and return the understandable message). Method `registerUser()` should call the method `validate()` and handle the exception. -If everything is ok, save user to the database (use method `saveUser()`), +If everything is okay, save the user to the database (use method `saveUser()`), if not, print the message "Your passwords are incorrect. Try again.". -#### [Try to avoid these common mistakes while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/exceptions/password-validation) +#### [Try to avoid these common mistakes while solving task](./checklist.md) diff --git a/checklist.md b/checklist.md index 27d6f0bc9..6a8fb7828 100644 --- a/checklist.md +++ b/checklist.md @@ -1,27 +1,26 @@ ### Common mistakes -#### Don't use commented code. +#### Don’t use commented code. It's important to develop good practices from the very beginning and fix bad ones. Pushing commented code belongs to the second group. -So always check the final solution for absence of commented code. -The main problem is that commented code adds confusion with no real benefit, because while reading the code +So always check the final solution for the absence of commented code. +The main problem is that commented code adds confusion with no real benefit because while reading the code with commented lines in it you will waste time analyzing its purpose and the reason it was added in the first place. -#### Don't complicate if-else construction. [Detailed explanation](https://www.youtube.com/watch?v=P-UmyrbGjwE) +#### Don’t complicate if-else construction. [Detailed explanation](https://mate-academy.github.io/jv-program-common-mistakes/java-core/complicated-if-else.html) #### Be attentive about the class you extend to declare your exception. Should it extend `RuntimeException` or `Exception` and why? (double check task description) -#### Don't create unneeded variables. -Try to keep your code simple. That is one of the core principle in programming. If you create a variable without any -particular reason in mind - think twice if it is required and whether we can complete task without it and we won't +#### Don’t create unneeded variables. +Try to keep your code simple. That is one of the core principles of programming. If you create a variable without any +particular reason in mind - think twice if it is required and whether we can complete the task without it and we won't decrease code readability. #### Remember about informative names of the variables. #### Don't complicate your code with a lot of empty lines. - +``` Bad example: -```java public int add(int a, int b) { int result = a + b; @@ -30,9 +29,8 @@ public int add(int a, int b) { return result; } -``` + Good example: -```java public int add(int a, int b) { return a + b; } diff --git a/pom.xml b/pom.xml index c8b22c951..f7e3fc1c9 100644 --- a/pom.xml +++ b/pom.xml @@ -9,10 +9,9 @@ 1.0-SNAPSHOT - 11 + 17 UTF-8 UTF-8 - 3.1.1 https://raw.githubusercontent.com/mate-academy/style-guides/master/java/checkstyle.xml @@ -31,7 +30,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.1.1 + 3.3.0 compile