On Dec 7, 2012, at 1:08 PM, 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 > > than > > if (expres) { > action > } > > or > > if (expres) > action > > 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?
My preference is: if (expression) { action } but also, especially if it adds readability, and when expression and action are short, the following is acceptable: if (expression) action On the other hand: if (expression) action should be avoided for the reasons you have mentioned. My 2 cents. Jacopo > > Thanks > > Jacques