Timeline for Java convention for if/else if order
Current License: CC BY-SA 3.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 6, 2013 at 19:25 | vote | accept | vainolo | ||
| Oct 5, 2013 at 4:46 | comment | added | Kaydell | I like a series of if-else-if-else and virtually always have an else at the end. Similarly for a switch-statement, I virtually always have a default case. I think that it's just a good idea to always consider every case, and if a case is "impossible" then have an assert statement there (if not throw an exception), and to be sure to turn on assertions for debugging and for testing. | |
| Oct 4, 2013 at 16:00 | history | edited | Konrad Morawski | CC BY-SA 3.0 | edited body |
| Oct 4, 2013 at 15:30 | history | edited | Konrad Morawski | CC BY-SA 3.0 | mind you, not zou :) QWERTZ layout |
| Oct 4, 2013 at 15:16 | history | edited | Konrad Morawski | CC BY-SA 3.0 | deleted 3 characters in body |
| Oct 4, 2013 at 12:29 | comment | added | Mike Partridge | When the difference in efficiency is negligible as in this case, readability is most important. Simplifying conditionals by extracting and naming their components is a great way to improve readability. | |
| Oct 4, 2013 at 12:17 | comment | added | Konrad Morawski | @vainolo yes it's longer by three lines, but I think it actually improves the readability (since your conditions are given meaningful names) and so the trade off is worth it. Of course ultimately it comes down to taste | |
| Oct 4, 2013 at 12:09 | comment | added | vainolo | Very interesting idea. Only thing I don't like about it is that it makes the code longer, which makes it "harder" to read. But otherwise it is very elegant. | |
| Oct 4, 2013 at 12:01 | history | edited | Konrad Morawski | CC BY-SA 3.0 | deleted 2 characters in body |
| Oct 4, 2013 at 11:02 | history | edited | Konrad Morawski | CC BY-SA 3.0 | added 23 characters in body |
| Oct 4, 2013 at 10:56 | history | answered | Konrad Morawski | CC BY-SA 3.0 |