Timeline for Java convention for if/else if order
Current License: CC BY-SA 3.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 15, 2016 at 9:24 | comment | added | firtydank | I usually "cheat" in this case by putting in a log statement: 'else if (a >=5 && a <= 10) {LOG.debug("Nothing to do, because ...")}'. Keeps the compiler and checkstyle happy AND provides a hint to future maintainers that you actually thought about it. | |
| Oct 8, 2013 at 11:23 | comment | added | Bart van Ingen Schenau | @gnat: Fair enough that you believe them to be duplicates. I don't, but lets agree to disagree on that one. With regard to not mentioning "else-statements", for me the else is part and parcel of the if. An if-statement may or may not contain an else part (or even an elif part), but I don't consider those to be separate statements. | |
| Oct 8, 2013 at 10:23 | comment | added | gnat | @BartvanIngenSchenau I believe these are dupes. And it's interesting how "conveniently" you omit else-statements in your analysis of the questions | |
| Oct 8, 2013 at 9:49 | comment | added | Bart van Ingen Schenau | @gnat: Your 'duplicate detector' seems to have malfunctioned here. The only relation between this Q and the two you mentioned as possible duplicates is that they concern if-statements. | |
| Oct 6, 2013 at 19:25 | vote | accept | vainolo | ||
| Oct 4, 2013 at 15:44 | comment | added | eidsonator | What about if a is less than or equal to zero? Is this supposed to only handle positive numbers? | |
| Oct 4, 2013 at 11:46 | review | Close votes | |||
| Oct 8, 2013 at 9:49 | |||||
| Oct 4, 2013 at 11:29 | comment | added | Pieter B | In your example it's ok, but in other cases where a is not an int but for instance a property, the mere checking of a multiple times can have sides effects. | |
| Oct 4, 2013 at 11:28 | history | edited | gnat | edited tags | |
| Oct 4, 2013 at 11:27 | comment | added | gnat | possible duplicate of Elegant ways to handle if(if else) else and of Are too many if-else statements for validation bad? | |
| Oct 4, 2013 at 10:56 | answer | added | Konrad Morawski | timeline score: 11 | |
| Oct 4, 2013 at 8:51 | answer | added | MrSmith42 | timeline score: 11 | |
| Oct 4, 2013 at 8:44 | history | asked | vainolo | CC BY-SA 3.0 |