private String executeSelect(int action, Form mform, HttpServletRequest request) { switch (action) { case 1: { return pageChooser(mform, request); } case 2: { return pageChooser(mform, request); } case 4: { return pageChooser(mform, request); } case 3: { return pageChooser(mform, request); } } return pageChooser(mform, request); }
There’s a need to comment?
Source can’t be disclosed
March 28th, 2011 at 21:50
I’m surprised he didn’t put the default case 😀
March 28th, 2011 at 22:45
I can bet that he tried!
But the compiler raised an error at the last return, “code unreachable” 😀
March 31st, 2011 at 09:37
ahaha you are right 🙂
I think that these examples would be even more enjoyable if we could follow their mental processes.
When i find such programing pearls and It is possible to ask to the author: “WHY?” , the explaination is often funniest than the code.
March 31st, 2011 at 11:08
I hope to talk right about such arguments, here in comments!
Things like ‘howintheworld anyone would come at THIS!!’ =)
With this one, I think, the developer come to this ‘solution’ after a few iteration… the application was intended to do several actions, but after some pruning only one lasts and the code was leaved as it was =)