It's important to develop good practices from the very beginning and fix bad ones. Pushing commented code belongs to the second group. So always check the final solution for absence of commented code. The main problem is that commented code adds confusion with no real benefit, because while reading the code with commented lines in it you will waste time analyzing its purpose and the reason it was added in the first place.
Don't complicate if-else construction. Detailed explanation
Should it extend RuntimeException
or Exception
and why? (double check task description)
Try to keep your code simple. That is one of the core principle in programming. If you create a variable without any particular reason in mind - think twice if it is required and whether we can complete task without it and we won't decrease code readability.
Bad example:
public int add(int a, int b) {
int result = a + b;
return result;
}
Good example:
public int add(int a, int b) {
return a + b;
}
Hardcoding reduces the flexibility of the code by forcing actual values into the source code.
Your code should be easy to read. Move all hardcoded values to constant fields and give them informative names.