I'm not a committer, so take my advice any way you like.

/me ascends high horse

An empty loop is 99.9% of the time a coding error. There's a reason
why pmc, checkstyle and findbugs trigger on this type of programming.
In my opinion, writing code that clearly shows intent is a pre, and
code that doesn't look like a bug even better. Empty blocks are bad
code, unless they override a method or provide an empty implementation
to an interface method. If you do need an empty block, you can
probably rewrite the code such that the empty block is no longer
necessary, or if that hides the intent even worse, provide a comment
that you intentionally left the block empty. Your future maintainers
will thank you for that.

/me descends high horse

That said, this can easily be considered a bike shed discussion, so
I'll leave it at this.

Martijn

On Tue, Sep 1, 2009 at 1:49 PM, Greg Brown<[email protected]> wrote:
>> It's legal and technically correct Java, but I prefer to write such
>> things like this:
>>
>>  while (iterator.hasNext()) {}
>>
>> to make it obvious that it's an empty block.
>
> If others feel strongly that this makes the intent more explicit, I will
> change it.
>
> What about cases like this:
>
> if (...) {
>    // Do something meaningful
> } else if (...) {
>    // Do something meaningful
> }
>
> Should we also include an empty else block to complete the conditional?
>
>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.0

Reply via email to