I would definitely do this refactoring to make the code more readable. Now you 
still have the same code in the extracted method. I would probably begin by 
refactoring that big condition. Maybe parts of it can be moved somewhere else 
(to "call" class for example). If so then this might simplify the condition 
significantly. In such a way I wouldn't introduce State pattern. From the code 
you presented it seems it would be quite challenging to do so.

David.

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 15, 2007 1:48
To: David Pokluda; [email protected]
Subject: RE: [patterns-discussion] Design pattern recommendation

Thanks David for your prompt response. I presume after refactoring the code for 
readability then the next step would be to introduce the State Design pattern 
for conditionals such as the one I have ?
Regards,
Aswin.

David Pokluda <[EMAIL PROTECTED]> wrote:
This code is totally unreadable. Whenever I have a complex condition that is 
hard to use I try at least ExtractMethod refactoring 
(http://www.refactoring.com/catalog/extractMethod.html) so that I can at least 
read the code. You can further improve readability with ReverseConditional 
refactoring (http://www.refactoring.com/catalog/reverseConditional.html). You 
can also take a look at 
http://www.refactoring.com/catalog/consolidateConditionalExpression.html.

David.

________________________________
From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] [EMAIL 
PROTECTED]
Sent: Wednesday, November 14, 2007 6:36 PM
To: [email protected]
Subject: [patterns-discussion] Design pattern recommendation
Hello to all the four who replied (I guess a Gang of Four did reply to my 
message!!)
Thanks for all the suggestions. I will certainly look at all of them closely. 
Though it looks I may need the State pattern. I will also buy that book that 
was recommended.

In any case here is the code thats hard to read

Basically thats the code that I am trying to refactor ( I have relabeled the 
methods )

if (call.isNothingReturned() && (cCall.hasLockingCondition() || 
getUtility().usesConfig() )
                && (!call.shouldBuildObject()) && 
(getUtility().externalWriteUtility() || (!call.hasParameters())) && 
(!call.isWriteRequired()))
________________________________
Get easy, one-click access to your favorites. Make Yahoo! your 
homepage.<http://us.rd.yahoo.com/evt=51443/*http:/www.yahoo.com/r/hs>




________________________________
Never miss a thing. Make Yahoo your 
homepage.<http://us.rd.yahoo.com/evt=51438/*http:/www.yahoo.com/r/hs>
_______________________________________________
patterns-discussion mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/patterns-discussion

Reply via email to