Top 10 tips to become a good Java programmer?

There are many rules or best practices that Java programmers should follow. This article outlines the 10 most important rules or precepts that every developer should follow. Failure to follow them can lead to catastrophic consequences.

1. Add comments to your code._Everyone knows this, but not everyone does it. How many times have you "forgot" to add a note? Indeed, comments don't add any functionality to your program. But how many times have you looked at code you wrote 2 weeks ago and you can’t remember what it does? You're lucky, you wrote the uncommented code yourself, and you still have residual impressions in your mind. Unfortunately, most of the time, the code was written by someone else, and that person has probably left the company. There's a proverb that goes: "What comes around, comes around," so programmers should be considerate of each other (and yourself) and add comments to your code.

2. Don’t complicate simple things (Donotcomplicatthings)._I have done this before, and I believe you have done the same. Developers tend to solve simple problems in complex ways. We introduced EJB into a system with only 5 users, implemented a framework for an application that did not need a framework, used properties files, used object-oriented solutions, and used threads, which were not needed at all. Why do you do this? Some people may not know there is a better solution, but others may do it intentionally to learn something new, or just because it's fun. For those who don't know a better solution, listen to the advice of experienced programmers. For those of you who complicate your designs purely for personal purposes, I suggest you be a little more professional.

3. Remember - "Lessis more" is not always better (KeepinMind_"Lessismore" is not always better)._ Efficient code is a good thing, but in many cases, it is not the fewer lines of code. The higher the efficiency.

4. Do not "hardcode" (Nohardcodingplease)._Due to time constraints, developers will always forget or deliberately ignore this item. Another possibility, however, is that by following this commandment, we won’t be stuck in a “time crunch.” How long does it take to define a staticfinal variable and add one line of code?

5. Do not invent your own frameworks._It is no exaggeration to say that there are already thousands of frameworks, most of which are open source. Many frameworks are perfect solutions and have been used in thousands of systems. We just need to focus on the latest popular frameworks and be at least superficially familiar with them. One of the most successful and widely used examples is the Struts framework. This open source web framework is an excellent choice for building web systems. Don't try to construct your own version of Struts, you will be exhausted. But you must remember commandment No. 2 (Translation: the original text is "No. 3", obviously incorrect) - Don't complicate simple things. If the system you want to develop only has 3 interfaces, don't use Struts. For such a system, there are not enough things that need to be "controlled" (Annotation: Struts divides the interface into MVC, and C is controller, so the author said thereisn' tmuch "controlling" required).

6. Say no to Print lines or strings (Sayno to Print lines and String Concatenations)._I know that for the convenience of debugging, programmers like to use System.out.println everywhere, and then delete it after saying it to themselves.

But we often forget to delete these lines or are unwilling to delete them. We use System.out.println for testing. Why do we need to change the code after testing? The Java course believes that this is likely to result in accidentally deleting a line of code we need. Don't underestimate the dangers of System.out.println.