Re: Control Flow Coding Style
"Johannes Brodwall" <[email protected]>
| Newsgroups | gmane.comp.programming.language-of-the-year |
|---|---|
| Message-ID | <[email protected]> |
Consider
Object doIt() {
Object result = null;
for ( Object candidate : potensials ) {
if ( matches(candidate) ) {
result = candidate;
break;
} else {
// What?!?
}
}
return result;
}
versus
Object doIt() {
for ( Object candidate : potensials ) {
if ( matches(candidate) ) {
return candidate;
}
}
return null;
}
Which one is most likely to contain bugs?
The only coding standard I have seen that has come close to working
is: Don't write crappy code.
~Johannes