As usual, let’s take a look at the transcript (or the image above):
How is this a problem? Code with lots of branches is a design smell; don’t do that. Also, consider using the switch statement, which is getting more powerful with recent java releases. Or better, switch to Kotlin which has a nice when statement that is a bit more sane than switch or if else garbage.
I don’t think I ever said it was a problem. I was acknowledging the fact that the Java grammar doesn’t contain an else if terminal symbol. Of course, the content was geared toward beginners (i.e. my students), so I chose not to dig into compilers. Instead, I shared an example they could easily understand.
Naturally, the example is purely for the sake of argument—not something you should put in production code. Of course, you’re welcome to lecture me on which tools I should be using.
Sometimes, I feel like people don’t even read what I’ve written. They’re so concerned about asserting their cognitive dominance, they don’t even stop to think: “hey, is what I’m saying adding any value to the conversation?” The answer is almost always no, but I figured I’d share what they had to say anyway. Oh, and I shared my response because I think it’s funny.
If you came from the Wall of Shame, here are links to the previous and next comments. Also, here’s a link back to the Wall of Shame.