Thanks Adam, Jacopo,
Actually I was wondering while reading "Java Concurrency in Practice" where
Brian Goetz uses
>> if (expres)
>> action
Some co-workers are also using it. I know some (new) languages also use it as
at std way.
I totally agree with you Adam about scanning code :/
Jacques
Adam Heath wrote:
> On 12/07/2012 06:08 AM, Jacques Le Roux wrote:
>> Hi All,
>>
>> This is a personal question not specifically related to OFBiz nor any
>> projects, just curious (and refreshing ;o)
>>
>> I'm seeking opinion about "one line" vs "multi lines w/t brackets" vs "multi
>> lines w/out brackets" for "if" and "for" expressions
>>
>> I mean
>>
>> I personally prefer something like
>>
>> if (expres) action
>
> When scanning code, 'sameness' goes into the background. If there are
> differences, it stands out. Differences also make it harder to
> process, as it takes the brain longer to realize it can skip it.
>
> If some if-blocks have brackets, and some don't, then that is a
> difference, and slows down understanding.
>
>> than
>>
>> if (expres) {
>> action
>> }
>
> My preferece.
>
>
>>
>> or
>>
>> if (expres)
>> action
>
> if (expres)
> action
> else
> other-action
>
> This is ugly. Adding additional actions inside the branch(s) is
> confusing, without the {} already there.
>
>
>>
>> The reason is that IMO it prevents
>> 1) to type useless brackets (with a French keyboard for instance brackets
>> are not easy)
>> 2) when you have no brackets there are less risks to confuse, and wrongly
>> add lines below action "thinking" they will be part of
>> the action
>>
>> Of course if the expression in action is long that's another story.
>> And then I still prefer to put brackets to be sure (but I'm a lot tempted to
>> not put them ;o)
>>
>> Your opinions?