That is why I said religious flame wars.
If or case could be replaced by the factory design pattern in OO (
Factory method pattern - Wikipedia ) in many cases. In a nutshell: Instead of branching with an if else or case statement you can put each branch into a distinct classes which inherit from the same parent. Some purists think every if or case should be replaced by it. I use the factory pattern very often, but I also use if an case statement.
Since we don't live in a black or white world, but in a world that comes in all different shades of grey - it is up to us how we craft our code. Whatever rule you hear - you have to take it with a grain of salt because - most likely - you will encounter cases where it does not make sense to apply them as you read them in a book. Sometimes you need to come up with your own variant.
There is a subtle difference between "should be avoided" and "must no be used". Should be avoided means that you will likely come up with a case where it makes sense to use it.
Even when it falls into the "must not be used" category - like share locks - I can come up with a case where it makes perfect sense to use it to your advantage for a neat solution that otherwise wouldn't hold water ...