From 97ba460ba80327a9ae7d4f334c20562d4bbe26fb Mon Sep 17 00:00:00 2001 From: Bohdan Chupika Date: Thu, 12 Oct 2023 16:16:43 +0300 Subject: [PATCH] update checklist.md (#1182) --- README.md | 3 ++- checklist.md | 16 ++++++++-------- pom.xml | 10 ++-------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index fa2c46edf..a85c64940 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,5 @@ Make your `ArrayList` behave the same way as `java.util.ArrayList` (it should ha Throw custom `ArrayListIndexOutOfBoundsException` in case the index passed to any of the methods is invalid. Throw `NoSuchElementException` in `remove(T element)` if there is no such element present. -#### [Try to avoid these common mistakes while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/collections/array-list.html) + +#### [Try to avoid these common mistakes while solving task](./checklist.md) diff --git a/checklist.md b/checklist.md index 0d5a504ca..42d23d047 100644 --- a/checklist.md +++ b/checklist.md @@ -1,6 +1,6 @@ ## Common mistakes (jv-array-list) -#### Don't begin class or method implementation with empty line. +#### Don't begin class or method implementation with an empty line. Remove all redundant empty lines, be careful :) #### Don't use Objects, Arrays, or any other util class. #### Any magic numbers should be constants @@ -27,13 +27,13 @@ public class Shelf { } } ``` -#### Don't complicate if-else construction. [Detailed explanation.](https://www.youtube.com/watch?v=P-UmyrbGjwE&list=PL7FuXFaDeEX1smwnp-9ri8DBpgdo7Msu2) +#### Don't complicate if-else construction. [Detailed explanation.](https://mate-academy.github.io/jv-program-common-mistakes/java-core/complicated-if-else.html) #### Don't create repeating code. -If the logic of your code repeats - move it to the separate private method. For example, the index check for `get()`, `set()` and `remove()` methods should be moved to the separate method. +If the logic of your code repeats - move it to a separate private method. For example, the index checks for the `get()`, `set()`, and `remove()` methods should be moved to a separate method. -There is even a software design principle called [DRY](https://dzone.com/articles/software-design-principles-dry-and-kiss) that urges not to repeat yourself. +There is even a software design principle called [DRY](https://dzone.com/articles/software-design-principles-dry-and-kiss) that urges you not to repeat yourself. #### Use informative names for your variables and methods. -Do not use abstract words like `string` or `array` as variable name. Do not use one-letter names. +Do not use abstract words like `string` or `array` as variable names. Do not use one-letter names. By the name of the variable, it should be clear what it is responsible for. The name of the method should make it clear what it does. Bad example: @@ -58,14 +58,14 @@ Another good example: } } ``` -In the first example we have `grow()` with `if` inside. +In the first example, we have `grow()` with `if` inside. This means that sometimes the array grows and sometimes it doesn't. When a developer who reads the code sees a call to the `grow()` method, -he thinks that the array will be increased. And only if he reads the body of the `grow()` method, he will understand that the array does not always grow. +he thinks that the array will be increased. Only if he reads the body of the `grow()` method, he will understand that the array does not always grow. The method name says nothing about this conditional logic. #### Don't create redundant variables. Redundant variables are confusing and make your code less clean and much more difficult to read. Not to mention they occupy stack memory. #### Use [System.arraycopy()](https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#arraycopy-java.lang.Object-int-java.lang.Object-int-int-) to move your array elements. #### Resize the array in a separate method. -According to one of the important principles called **Single Responsibility** principle, any software component must have only one responsibility, that is, to be in charge of doing just one concrete thing. +According to one of the important principles called the **Single Responsibility** principle, any software component must have only one responsibility, that is, to be in charge of doing just one concrete thing. #### Make your exceptions informative. If you throw an Exception, you should always add an informative message so that it would be clear from the stack trace what exactly went wrong. diff --git a/pom.xml b/pom.xml index 5a0b4d9f6..b09355224 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 @@ -25,18 +24,13 @@ 4.12 test - - org.apache.maven.plugins - maven-checkstyle-plugin - 2.17 - org.apache.maven.plugins maven-checkstyle-plugin - 3.1.1 + 3.3.0 compile