Re: Refactoring to Strategy: What happens with Conditional Logic?

Peter Bell <[email protected]> Mon, 22 Nov 2010 10:48:37 -0500
Newsgroups gmane.comp.programming.refactoring
Message-ID <[email protected]>
Have you read the GoF book - specifically the strategy pattern?

http://en.wikipedia.org/wiki/Strategy_pattern

You are not removing the logic per se - if you need 10 different ways of doing something, you can't make any of those disappear - that's essential complexity. You can however put the 10 different strategies into different objects responsible for the details of each of the 10 different approaches. Generally if you've got a big case statement with a bunch of custom logic in each, this is one way to get the method size and complexity under control.

Best Wishes,
Peter

On Nov 22, 2010, at 10:29 AM, katerinaxristopoulou wrote:

> Hello all,
> 
> I have recently read "Refactoring to Patterns" by J.Kerievsky and I have a question regarding "Refactoring Conditional Logic with Strategy". I really don't understand what happens with conditional logic and how it is eliminated. I feel like the conditional logic is somehow moved to the client rather than being eliminated, but i'm not sure about that cause then, the problem with complicated conitional logic still remains.
> 
> What's your opinion? Is it more clear for someone else?
> 
> Thanks,
> 
> Katerina
> 
> 



[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/