aspose file tools*
The moose likes Java in General and the fly likes Survey about continue, break and multiple return statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Survey about continue, break and multiple return statements" Watch "Survey about continue, break and multiple return statements" New topic
Author

Survey about continue, break and multiple return statements

Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

A couple of times a year the discussion about whether to use continue, break and multiple return methods (in a single method) lights up. Every programmer has his own opinion about this it seems. To gain insight into this matter we started, as part of a course, a survey to see what people think about it. The survey consist of 2 parts, what you think about the usage of the statements and code fragments of which you need to find the outcome.

We would really appreciate it if you would fill in this survey. It won't take that long. Of course the results will be announced here. Maybe we can finally conclude this discussion...

The survey

Thank you very much,
Wouter


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

The survey has been closed. Thank you for participating. We are now gathering the results and will publish them soon.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

I'm looking forward to hearing the results
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Oh... will you publish the results for all who took.. or only top scorers i am eager to see the marks... but only can see you publish all the results... perhaps from bottom to top might be even more easier
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

I don't think that's the point of the survey :P
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
oh ... we wont know how our marks for the test?
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

Since the survey was anonymous, it seems unlikely.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

I abandoned the survey when it seemed to be more about remembering the detail of auto-boxing and less about "continue, break and multiple return statements".


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

I think the point was to show that with some of the constructions, it is hard to understand and/or read the code.

I copied the different questions and had a discussion yesterday with some colleagues. Some of the code-examples are doing the exact same thing. Only that where you use continue, break and multiple returns, most of the gang got the result wrong.

I will use some variants of the code examples in my classes to show how to write and how to not. Thanks Stephan Wouter for the excellent survey.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

Hang on hang on, as much as I would like to take the credit, it's Wouter's survey. I have absolutely nothing to do with it
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

The survey was anonymous so you won't get your individual scores back. The results will probably be published after the weekend. A small teaser: one question was answered incorrectly by 60% of the respondents.

And thank you Stephan
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

James Sabre wrote:I abandoned the survey when it seemed to be more about remembering the detail of auto-boxing and less about "continue, break and multiple return statements".
The survey only has one question where an Integer is compared to an int. In the other cases the comparison is int vs. int. Only in the case of a comparison between an Integer and and Integer, which the survey didn't contain, must the details of auto-boxing be known (i.e. the auto-boxing caches).
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
A small teaser: one question was answered incorrectly by 60% of the respondents.


Which question was that?
Megha kharde
Greenhorn

Joined: Nov 24, 2010
Posts: 19
for(;;){
continue;
break;
return 0 ;
}
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
I missed to answer this particular question sir
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

That code won't even compile to due to unreachable statements.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Megha kharde
Greenhorn

Joined: Nov 24, 2010
Posts: 19
try this

for(;;){
System.out.println(" ");
if(true) continue;
else if(true)break;
else return 0 ;
}
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Wouter Oet wrote:The results will probably be published after the weekend.

hi was the results announced?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

I'm sorry. There are some problems with entering our grade into the schools gradingsystem (read: the system that doesn't work all the time, if it works it works partially, students hate it, teachers hate it). Therefore you'll have to wait a little longer. I do hope and think that the problems will be solved quickly.
 
 
subject: Survey about continue, break and multiple return statements