Skip to content

Commit

Permalink
update checklist.md (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
boroda4436 authored Oct 12, 2023
1 parent faec460 commit b4ce832
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 9 additions & 11 deletions checklist.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
### Common mistakes

#### Don't use commented code.
#### Dont 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)
#### Dont 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
#### Dont 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;
Expand All @@ -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;
}
Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
<version>1.0-SNAPSHOT</version>

<properties>
<jdk.version>11</jdk.version>
<jdk.version>17</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.checkstyle.plugin.version>3.1.1</maven.checkstyle.plugin.version>
<maven.checkstyle.plugin.configLocation>
https://raw.githubusercontent.com/mate-academy/style-guides/master/java/checkstyle.xml
</maven.checkstyle.plugin.configLocation>
Expand All @@ -31,7 +30,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<version>3.3.0</version>
<executions>
<execution>
<phase>compile</phase>
Expand Down

0 comments on commit b4ce832

Please sign in to comment.