From: Mike Ratcliffe on 22 Mar 2010 08:32 We have been having a lively debate at work about whether or not we should use brackets with conditionals that contain AndAlso. This is because AndAlso has precedence over OrElse and I say that it makes code more manageable if brackets are included. False OrElse True AndAlso False will return False because AndAlso has precedence over OrElse. I say that this is better written as: False OrElse (True AndAlso False) What do you think?
From: AMercer on 22 Mar 2010 09:24 I agree with you - include the parentheses. More so with less often used constructs, and more so with more complex expressions. Intent will be clear to the new guy next year whose first assignment is making a mod to this code. "Mike Ratcliffe" wrote: > We have been having a lively debate at work about whether or not we > should use brackets with conditionals that contain AndAlso. This is > because AndAlso has precedence over OrElse and I say that it makes > code more manageable if brackets are included. > > False OrElse True AndAlso False will return False because AndAlso has > precedence over OrElse. > > I say that this is better written as: > False OrElse (True AndAlso False) > > What do you think? > . >
From: Armin Zingler on 22 Mar 2010 09:44 Am 22.03.2010 13:32, schrieb Mike Ratcliffe: > We have been having a lively debate at work about whether or not we > should use brackets with conditionals that contain AndAlso. This is > because AndAlso has precedence over OrElse and I say that it makes > code more manageable if brackets are included. > > False OrElse True AndAlso False will return False because AndAlso has > precedence over OrElse. > > I say that this is better written as: > False OrElse (True AndAlso False) > > What do you think? Agreeing with AMercer. -- Armin
From: Cor Ligthert[MVP] on 22 Mar 2010 09:52 Mike, This are question which completely depends on the knowledge of the users. Some say parentheses make it easier to read, others say you would not put things in code without a function, because then others become suspicious and take time in it to examine why you did it and when they cannot find it, take even more time. However, personally I do it too, because I am simply to lazy to reminds me what goes first especially in a not situation. But to say that it is better, like I wrote, it is mainly because I'm lazy. jmo Cor "Mike Ratcliffe" <sabine.michael.ratcliffe(a)gmail.com> wrote in message news:1693dfce-1557-4369-889c-c271c72a3bf6(a)m37g2000yqf.googlegroups.com... > We have been having a lively debate at work about whether or not we > should use brackets with conditionals that contain AndAlso. This is > because AndAlso has precedence over OrElse and I say that it makes > code more manageable if brackets are included. > > False OrElse True AndAlso False will return False because AndAlso has > precedence over OrElse. > > I say that this is better written as: > False OrElse (True AndAlso False) > > What do you think?
From: Herfried K. Wagner [MVP] on 22 Mar 2010 10:18
Am 22.03.2010 13:32, schrieb Mike Ratcliffe: > We have been having a lively debate at work about whether or not we > should use brackets with conditionals that contain AndAlso. This is > because AndAlso has precedence over OrElse and I say that it makes > code more manageable if brackets are included. > > False OrElse True AndAlso False will return False because AndAlso has > precedence over OrElse. > > I say that this is better written as: > False OrElse (True AndAlso False) > > What do you think? I don't like the brackets, but I'd suggest to use them because I doubt that anybody who will work on the code is aware of the precendence rules ;-). -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> |