Checklists are always helpful! They provide a quick check to ensure consistency and completeness in carrying out a task efficiently and effectively...
For further actions, you may consider blocking this person and/or reporting abuse
Id suggest that constants files only be used if needed in multiple places and apart from reference to a single class. It the usage will always be in regards to a single class (or within a single class) then put the constants in that class.
Thanks for pointing it out. I totally agree with you. Will update the article.
Great article and guidelines.
I just don't agree with number 12 as I believe self-documented code is better code.
I think comments are really useful in very specific cases, where your code can't explain what you want to achieve. About the author and date, the VCS covers that part of the comment.
In number 16 I would just add a default case to every switch case for enums, it is a good practice and helps developers when they add a new value to the enum.
Keep going!
Thanks @pedroduarten9 for pointing it out. I agree with you on both points.
However, on number 12 it is advised for Java beginners to add comments on class/method which helps in Javadoc, not on the code to explain. As you say - comments are really useful in very specific cases. I'll update the article to mitigate this confusion.
Cheers!
Thanks for the guide.
Regarding the number 17, I feel like the example looks not very valid eventhough the point is valid.
Thanks for pointing it out. I've fixed it in the article.
Please have a look.
The code example is wrong.
In both cases new Person is executed and there is no object reuse. Except that the second example obfuscates escape analysis, so I'd argue that its inferior.
Thanks for pointing it out. I've fixed it in the article.
Please have a look.
I still don't get what you're trying to show here.
Java won't optimize anything in these cases because you're adding the person object to a list, so its not a short lived object.
My bad. I didn't give it much thought.
Thanks for help!
Great post!
In Intellij the default formatting rules (point 3) make 4,9 and 10 redundant because it does them automatically.
In addition, in Intellij you can set the flags "Add unambiguous imports on the fly" & "Optimize imports on the fly" to save you some typing even before the formatting is pressed.
:)
Thanks.
I totally agree with you. IDE (IntelliJ, Eclipse) provides built-in features for automatic formatting and cleanup.
Good suggestion on One-liners, one-liner code is difficult to debug.
8 looks more like C++ to me than Java.. Am I missing something?
It is actually Groovy. May be I should add simple Java code as an example.
But this article is called checklist for JAVA beginners. Groovy is not Java.
It is my bad. I code both in Java and Groovy. And I missed to change the example code before adding it to the article. However, I've updated it to Java already.
Thanks for pointing it out.