Clarification of "avoid if-else" advice [duplicate]
- by deviDave
This question already has an answer here:
Elegant ways to handle if(if else) else
21 answers
The experts in clean code advise not to use if/else since it's creating an unreadable code. They suggest rather using IF and not to wait till the end of a method without real need.
Now, this if/else advice confuses me. Do they say that I should not use if/else at all (!) or to avoid if/else nesting?
Also, if they refer to the nesting of if/else, should I not do even a single nesting or I should limit it to max 2 nestings (as some recommends)?
When I say single nesting, I mean this:
if (...) {
if (...) {
} else {
}
} else {
}
EDIT
Also tools like Resharper will suggest reformatting if/else statements. It usually concerts them to if stand-alone statement, and sometimes even to ternary expression.