Dennis Deems wrote:Depending on which banner of the holy war you march under. I was educated in the only-one-return school. Since then I have found that an early return can sometimes markedly improve code readability. I don't know if I would go out of my way to use one, but I wouldn't go out of my way not to, either.
I think it may have come from the days of mainframe langauges, because I was definitely taught that way (perhaps because methods tended to be much bigger in those days); but I tend to rebel against "always do this" rules unless I can see a good reason for following it.
The classic example is a '
switch' statement: I'll
always return from a
switch if I can; for one thing, it saves all those darn
breaks.
Winston