The implementation would be driven by the location of the "strategy
choosing" logic.

In the sample code you provided - the controlling logic in located in
a central location the executing that chooses the strategy to execute.
The Strategies themselves have no say in the matter.  However the
other path you can choose is to enable the Strategies to decide for
themselves what they may or may not handle. This allows the strategies
to evolve independently of one another.

So is the strategy switching logic pretty much static? or is there
more going on in choosing the strategy? If its pretty much static then
I think what you are doing is fine. It's simple enough and does its
job. I wouldn't force a pattern on if you don't have anything else you
are trying to manage.

Cheers.. Vivek

On Fri, 25 Mar 2005 13:06:37 -0500, Bill Bassler
<[EMAIL PROTECTED]> wrote:
> I'm trying to determine the most appropriate design pattern to implement
> for the following problem.
>
> I'm receiving an xml document whose structure contains an element defining
> a source. Each source's document contains a similar but distinct xml
> document. Each one of the distinct documents requires a distinct set of
> message processing steps. I have implemented the document specific
> processing steps/algorithm using the Strategy pattern. This works well at
> cleanly encapsulating the processing logic.
>
> The issue I'm trying to solve is - What's the most appropriate/cleanest way
> to inspect the source element in order to route the xml message to the
> appropriate Strategy for processing. Currently I use a switch statement to
> decide the processing.
>
> e.g.
>
> switch (enrollmentDoc.SelectSingleNod("/EnrollForm/Source").InnerXml.ToUpper
> ())
> {
>    case 1:
>       // Use Strategy 1
>    case 2:
>       // Use Strategy 2
> }
>
> This works, but I'm looking for something a little less clunky and
> hopefully more modular. I've looked at the Command pattern ... which seems
> to somewhat fit the task. Possibly the Chain of Command but I don't know
> that I need that level of processing flexiblity as what I need to do can be
> encapsulated pretty well in the Strategy.
>
> ===================================
> 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

Reply via email to