Skip to main content
8 events
when toggle format what by license comment
Oct 30, 2012 at 22:50 vote accept rlandster
Oct 30, 2012 at 18:46 comment added Guvante @Blrfl: I was referencing that repeated ifs are a bad example of too much nesting. You shouldn't be nesting repeated ifs anyway. I agree that in general unless you are talking about a minor amount of code, there is no reason to include else.
Oct 30, 2012 at 18:12 comment added Jimmy Hoffa @Blrfl pachinko machines hah, perfect analogy +1
Oct 30, 2012 at 17:51 comment added Blrfl @Guvante: Each if tests for a single condition and deals with it if the condition is true, and unless there's some alternate thing that has to happen if the condition is false, else ifs are unnecessary. We have a term around my office for code like dasblinkenlight's first snippet: "pachinko machines."
Oct 30, 2012 at 17:44 comment added Guvante To be fair, if you are just using repeated if's you can do else if.
Oct 30, 2012 at 17:38 comment added Tulains Córdova +1 True. Second OP case forces you to read carefully, then leaves you with a WTF. But... always try to make methods short. A return in the middle of a 200 lines method is also bad.
Oct 30, 2012 at 17:34 history edited Sergey Kalinichenko CC BY-SA 3.0
added 474 characters in body
Oct 30, 2012 at 17:28 history answered Sergey Kalinichenko CC BY-SA 3.0