Yes, you're going to have to think of the Strategies as subclasses, because in the strategy pattern that is what they are. Without the Strategy interface you couldn't be able to choose the Strategy without changing the context, so you would break the pattern. Whether you decide to use a switch statement, a parameterized factory method, or any other means to actually determine which Strategy to create and use, you will still need to return an interface.
Kind regards, Chad On Mon, 28 Mar 2005 07:19:12 -0500, Bill Bassler <[EMAIL PROTECTED]> wrote: > Hopefully where you have '// Use Strategy X' you are instantiating a > particular strategy object and then using that instance when you > instantiate your context object. If you are not doing that then you are > not really using the strategy pattern. > > Yes. This is where I'm instantiating the required Strategy object ... so I > think I'm O.K. I'm really trying to see if there's a pattern-based way to > determine which Strategy to instantiate instead of using a switch > statement ... which O.K. I guess ... doesn't use of the Factory method > pattern really refer to subclass creation. I guess I could think of the > Strategies as subclasses and then it fits. > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
