I have an if/else if structure that on some cases does nothing. From the code I have seen in my career, the "empty" case is normally left out. But when I wrote my code, it just doesn't feel right to leave this case out, but to show it as a real case that simply does nothing. For example, in a case where something is done when a number is below 5 and above 10, but in between nothing is done:
int a = 4
if(a < 5) {
do something
} else if(a >=5 && a <= 10) {
// do nothing
} else if(a > 10) {
do something else
}
The reason I thought this is a better option is because:
- The is how I though about the problem in my mind.
- This shows the reader of the code that I thought of all the possibilities and didn't forget one by mistake.
So I was wondering if this convention is either accepted by the programming community or it is shunned upon.