[JAVA] 5 things new programmers should be aware of

Introduction

In one case, an old programmer in his late 30s said. "When developing, copy and paste first" "If you move for the time being, it's OK" "I don't know what happened after I was gone."

I can't help it after I'm 30 years old, but I'm still in my 20s! I've summarized as much as possible what I want you to be aware of at least. If you are a new programmer, please read it. It's Java-based, but it's the same for other languages.

If you are a young programmer, please click here. Five things young programmers should be aware of

If you are a new leader, please click here. Five things new leaders should be aware of

5 things new programmers should be aware of

1. 1. Keep the code as simple as possible (maintainable code)

Emphasis is placed on "readability" rather than "ease of writing". It should be easy to understand even if you review it a few months later.

2. Understand all the code you write

Be sure to understand the code you wrote, even if you refer to the code of others. If you say, "I'm not sure because I copied the process," I'm beaten.

3. 3. Do not write unnecessary code

No need for a null check just in case. Check if necessary, do not check if not needed. In addition, there is no need for processing that never passes.

4. Don't write the same code over and over

Similar processing is made into a common method. If the processing is similar but the target class is different, use the interface or generics.

5. Write "meaningful comments" for complex processes that are not immediately apparent

It can get complicated. In such a case, write a comment that can be easily understood even after a few months.

About 1, concrete supplement

For example, follow the rules below ・ Use verbs for method names and nouns for variables so that they are easy to understand.

-Make the scope of methods, constants, and variables as small as possible (Be aware of public protected private, be aware of the location of constant and variable declarations)

・ Set limits for coding and protect (Specific values vary from site to site, so reference values are listed below)

・ Up to 3 nesting layers ・ Up to 50 lines per method ・ One class has 10 methods and up to 500 lines ・ Up to 20 classes in one package

If you want to know more, read the following book

[Readable Code](https://www.amazon.co.jp/%E3%83%AA%E3%83%BC%E3%83%80%E3%83%96%E3%83%AB%E3% 82% B3% E3% 83% BC% E3% 83% 89-% E2% 80% 95% E3% 82% 88% E3% 82% 8A% E8% 89% AF% E3% 81% 84% E3% 82 % B3% E3% 83% BC% E3% 83% 89% E3% 82% 92% E6% 9B% B8% E3% 81% 8F% E3% 81% 9F% E3% 82% 81% E3% 81% AE % E3% 82% B7% E3% 83% B3% E3% 83% 97% E3% 83% AB% E3% 81% A7% E5% AE% 9F% E8% B7% B5% E7% 9A% 84% E3 % 81% AA% E3% 83% 86% E3% 82% AF% E3% 83% 8B% E3% 83% 83% E3% 82% AF-Theory-practice-Boswell / dp / 4873115655)

Finally

Recently, there was a suggestion to use the old man again. It's scary.

Recommended Posts

5 things new programmers should be aware of
Things to be aware of when writing Java
Java Servlet should be aware of multithreaded environment
Things to be aware of when using devise's lockable
[Java] Things to be aware of when outputting FizzBuzz
[Java Silver] Things to be aware of regarding switch statements
Things to be aware of when writing code in Java
To be aware of easy-to-read code
[Java] Be aware of short circuits (short-circuit evaluation)
Basic rules to be aware of to write easy-to-read code
[Rails] When using ajax, be aware of "CSRF measures".
I want to be aware of the contents of variables!