Am 03/18/2016 09:37 AM, schrieb Patricia Shanahan:
Consider the case of an if-statement with a single statement in the
"true" branch only. For example:

if( someCondition ) return;

Should it be formatted on one line, as above, or on two lines:

if( someCondition )
return;

or on four lines:

if( someCondition )
{
return;
}

I dislike the single line format because it makes placing breakpoints hard.

+1
When coding with JavaScript I also avoid using too much simplification like putting code in a single line.

Setting brackets for a single condition can be a good thing - especially if it's shared code, so that everybody can work on it and has to understand the algorithm. Think about the case when the condition needs to be extended to more lines. It's very easy to overlook the ; that ends the if-statement or a condition. Everything else is than executed in any case afterwards.

OK, here with a "return" it's unlikely to put more code behind it. ;-)

So, if or not putting brackets here is sometimes a questions of taste. But there is also a good argument to do it.

My 2 ct.

Marcus


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org

Reply via email to