Amen to that.  If code is too complicated to understand, surely the best
thing is to refactor it!  If there are enough booleans in one expression to
justify de Morgan manipulation then lift some of them out, and as Richard
said, you have to also be aware of side-effects and performance issues of
(short-cut) evaluation of the expression.  This will almost always be more
sophisticated than an automated tool could calculate.

There are already the refactorings to make booleans more understandable -
Extract Variable and Extract Method are the obvious starting points.

Sorry about the rant - back to work.

Dan

> -----Original Message-----
> From: Vollmer, Thomas - CannonSA [mailto:[EMAIL PROTECTED]]
> Sent: 15 December 2001 01:37
> To: '[EMAIL PROTECTED]'
> Subject: RE: [Eap-features] Code Style - parenthesize boolean
> expressions
> 
> 
> Richard wrote:
> > Another issue is whether a boolean expression complex enough
> > so that you need automated tool to re-arrange it - whether the
> > coding style can get some improvement.
> 
> If I understand you correctly then that's exactly what I said:
> 
> > > If an expression is so complex that
> > > you need a tree-view to understand it, I would
> > > recommend to repeatedly apply the "Introduce
> > > Variable" refactoring to break it down.
> 
> I tend to agree with your other arguments. But then again,
> nobody said you could apply such functionality blindly.
> Kinda like the change signature refactoring.
> 
> Regards.
> -Thomas
> 
> > -----Original Message-----
> > From: Nemec, Richard [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, December 14, 2001 4:22 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [Eap-features] Code Style - parenthesize boolean
> > expressions
> > 
> > 
> > -xx
> > 
> > I simply don't like the whole thing. 
> > However, it's your preference to ask for it.
> > Just be sure you know what you're doing. Boolean operators in Java
> > are NOT the same thing as logical operators.
> > If you reorder, the operational result may be different.
> > function calls may have side effects (or performance impacts),
> > exceptions may be thrown or not (even without functions in
> > the expression), etc.
> > 
> > Another issue is whether a boolean expression complex enough
> > so that you need automated tool to re-arrange it - whether the
> > coding style can get some improvement.
> > 
> > r.
> > 
> > > -----Original Message-----
> > > From: Vollmer, Thomas - CannonSA [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, December 14, 2001 4:33 PM
> > > To: '[EMAIL PROTECTED]'
> > > Subject: RE: [Eap-features] Code Style - parenthesize boolean
> > > expressions
> > > 
> > > 
> > > Sounds reasonable. The tree-view of a boolean
> > > expression might be a bit too elaborate in my
> > > opinion. If an expression is so complex that
> > > you need a tree-view to understand it, I would
> > > recommend to repeatedly apply the "Introduce
> > > Variable" refactoring to break it down.
> > > 
> > > -Thomas
> > > 
> > > > -----Original Message-----
> > > > From: Thomas Singer [mailto:[EMAIL PROTECTED]]
> > > > Sent: Friday, December 14, 2001 11:23 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: RE: [Eap-features] Code Style - parenthesize boolean
> > > > expressions
> > > > 
> > > > 
> > > > At 12:46 14.12.2001 -0500, you wrote:
> > > > >I agree with Erb. Nontheless, "expression refactorings" would
> > > > >be nice to be able to refactor expressions so they show the
> > > > >intent or meaning most clearly (which of course, only the
> > > > >progammer can decide).
> > > > 
> > > > Agree.
> > > > 
> > > > >Along these lines, it would be nice if one could select
> > > > >a piece of a boolean expression and apply "de Morgan"
> > > > >style refactorings:
> > > > >
> > > > >!a && !b -> !(a || b) -> !a && !b
> > > > 
> > > > I meant this. Perhaps an extra dialog showing the 
> > > > tree-character of boolean 
> > > > expressions (with the ability to refactor them) would be cool.
> > > > 
> > > >         [&&]
> > > >      [!]    [!]
> > > >      (a)    (b)
> > > > 
> > > > or
> > > > 
> > > >         [||]
> > > >      (a)    (b)
> > > > 
> > > > 
> > > > >Don't know how useful this would be in practice,
> > > > >but it sure sounds worth exploring...
> > > > 
> > > > I believe, they would be *very* helpful, because a lot of 
> > > > complex boolean 
> > > > expressions cause a lot of bugs. Transforming them to better 
> > > > readable form 
> > > > lets you easier find bugs.
> > > > 
> > > > Tom
> > > > 
> > > > 
> > > > _______________________________________________
> > > > Eap-features mailing list
> > > > [EMAIL PROTECTED]
> > > > http://www.intellij.com/mailman/listinfo/eap-features
> > > > 
> > > 
> > > 
> > > ************************************
> > > If this email is not intended for you, or you are not 
> > responsible for
> > > the delivery of this message to the addressee, please 
> note that this
> > > message may contain ITT Privileged/Proprietary 
> Information.  In such
> > > a case, you may not copy or deliver this message to anyone.  
> > > You should
> > > destroy this message and kindly notify the sender by reply email.
> > > Information contained in this message that does not relate to the
> > > business of ITT is neither endorsed by nor attributable to ITT.
> > > ************************************
> > > 
> > > 
> > > 
> > > _______________________________________________
> > > Eap-features mailing list
> > > [EMAIL PROTECTED]
> > > http://www.intellij.com/mailman/listinfo/eap-features
> > > 
> > 
> > _______________________________________________
> > Eap-features mailing list
> > [EMAIL PROTECTED]
> > http://www.intellij.com/mailman/listinfo/eap-features
> > 
> 
> ************************************ 
> If this email is not intended for you, or you are not 
> responsible for the
> delivery of this message to the addressee, please note that 
> this message may
> contain ITT Privileged/Proprietary Information.  In such a 
> case, you may not
> copy or deliver this message to anyone.  You should destroy 
> this message and
> kindly notify the sender by reply email.  Information 
> contained in this
> message that does not relate to the business of ITT is 
> neither endorsed by
> nor attributable to ITT. 
> ************************************ 
> 
> 
> _______________________________________________
> Eap-features mailing list
> [EMAIL PROTECTED]
> http://www.intellij.com/mailman/listinfo/eap-features
> 


***************************************************************************************
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify [EMAIL PROTECTED] 
immediately.

This footnote also confirms that this email message has been swept for the 
presence of computer viruses.
***************************************************************************************

_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features

Reply via email to