Training memo. (For myself) ** * I have received a total tsukkomi, so I will correct it. Thank you for pointing out. 2019/11/14 **
When developing as a team, the readability of the program, that is, the readability, is important. ・ Actively comment. ・ It is better to make a habit of putting comments in the condition of the if statement.
For example, in the following conditions
sample
//a is equal to b or c is equal to d and e is not equal to f and g is not equal to h
if (a == b || (c == d && e != f) && g != h) {
//Processing content
}
Because there are multiple conditions and it is complicated Organize the conditions.
sample
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int h = 0;
if (a == b || (c == d && e != f) && g != h) {
System.out.println("true1");
}
if (a == b) {
System.out.println("true2");
} else if (c == d & e != f) {
if (g != h) {
System.out.println("true2");
}
}
result: true1 true2
sample
//Wrong processing
if (g != h) {
if (a == b) {
System.out.println("true2");
} else if (c == d && e != f) {
System.out.println("true2");
}
}
}
It depends on the processing content, but even if the number of lines increases a little It is said that there are many sites that emphasize simplicity and simplicity at a glance.
Recommended Posts