My question might get closed, but I'm curious about whether it's always required to add an "else" part to every "if" statement in coding. A senior programmer told me, "You should always have an 'else' part in every 'if' statement." However, what should we do if there's no reason to include an "else" part? I think this could lead to an interesting discussion.
That's a horrible idea. You end up with code of the form:
if (something) {
doSomething();
} else {
}
How anyone could think that's more readable or maintainable that not having an else
at all is beyond me. It sounds like one of those rules made up by people who have too much free time on their hands. Get them fired as quickly as you can, or at least move away calmly and quietly :-)