You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Phil Steitz <ph...@steitz.com> on 2005/03/06 15:14:50 UTC

[chain] Re: Why Template Method instead of Strategy in Commons Chain?

Jack,

Its best not to cross-post and when posting to one of the commons lists, 
you should start the subject line with the component name in brackets.

I can assure you that there is no "closed shop of ideas" here.  Posts 
are sometimes missed or misunderstood and sometimes the ideas don't 
resonate with others in the community. Nonresponse does not mean that 
the community is not open to new ideas.

If your questions or suggestions for improvement are about the 
implementation of [chain], it might be better to post them to 
commons-dev and/or open a Bugzilla ticket including patches showing what 
you have in mind.

Thanks!

Phil

Dakota Jack wrote:
> I inquired why the Template Method pattern is being used with Commons
> Chain instead of Strategy, but never got an answer.  Given that the
> choice seems so problematic, that surprised me.  Is that (no response)
> because there is no answer, or because it is a closed shop of ideas in
> open source, or because there is no time to consider such a stupid
> idea, etc.?
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [chain] Re: Why Template Method instead of Strategy in Commons Chain?

Posted by Dakota Jack <da...@gmail.com>.
Thanks for the note on the "component name in brackets", Phil.  I have
not posted much to commons and forgot.  Sorry!

There is a clear reason to cross post.  I have suggested to the people
in Struts, who are working on an implementation of  commons chain to
build a CoR for the RequestProcessor in Struts v1.3 and beyond, that
they should be using Strategy with commons chain rather than Template
Method.  I figured that the topic clearly was Struts related but that
people in commons chain might have a better idea on the vagarities,
etc. on that than the Struts people would have.

On the user versus development post, my experience is that when
discussing these fundamental things, whichever way I post, someone
will tell me to do the opposite.  I can point out many, many examples
of that.  I consistently get decorum answers as opposed to answers on
the substance.  In this case, too, the point is _largely_ user related
in the commons chain context.


Can you give me any idea why one would prefer to use commons chain
with Template Method rather that Strategy?  This seems to me to be
both a user and developer question for commons chain and clearly
relevant to Struts development and users who care about such things. 
(I have been told that development in Struts is only for actual work
on given code and that _general_ discussions like this should go on
users.  So, there you go?)

If you could response on the merits of this fairly simple but
fundamental issue, I would be more than happy.  Sometimes the
temperature on Apache lists for these sorts of discussion feel like
the descent into The Inferno by Dante, i.e. colder than hell!  Here
are the alternatives.  I think that the Strategy pattern is so
superior and so well know to be superior that the use of the Template
Method pattern just floors me.  I am completely open to being wrong on
this and would just like to have a discussion on it.  That should be
quick and easy thing to do.  I have found it, so far, to be
impossible.

Struts proposed v1.3 does the following in using commons chain for the
RequestProcessor:

STRUTS USE OF TEMPLATE METHOD IN PROPOSED v1.3

public abstract class AbstractPopulateActionForm implements Command {
 public boolean execute(Context context) throws Exception {
   // do stuff
   reset(actionCtx, actionConfig, actionForm);
   populate(actionCtx, actionConfig, actionForm);
   handleCancel(actionCtx, actionConfig, actionForm);
   return (false);
 }

 protected abstract void reset(ActionContext context,
                               ActionConfig actionConfig,
                               ActionForm actionForm);

 protected abstract void populate(ActionContext context,
                                                ActionConfig actionConfig,
                                                ActionForm
actionForm) throws Exception;

 protected String trimParameterName(ActionConfig actionConfig, String name) {
   // do stuff
   return stripped;
 }

 protected void handleCancel(ActionContext context,
                                          ActionConfig actionConfig,
                                          ActionForm actionForm)
throws Exception {
     // do stuff
 }
}

public class PopulateActionForm extends AbstractPopulateActionForm {
 private static final Log log = LogFactory.getLog(PopulateActionForm.class);

 protected void populate(ActionContext context,
                         ActionConfig actionConfig,
                         ActionForm actionForm) throws Exception {
    // do stuff
 }

 protected void reset(ActionContext context,
                      ActionConfig actionConfig,
                      ActionForm actionForm) {
    // do stuff
 }
}

Why not do the following?  Isn't that a better use of commons chain? 
What are the experiences of the users of commons chain?  Are there
any?  ///;-)

SUGGESTED USE OF STRATEGY

public class PopulateActionForm implements Command {
 private Helper helper;

 public void setHelper(Helper helper) {
     this.helper = helper;

 public boolean execute(Context context) throws Exception {
    // do stuff
   helper.trimParameterName(actionCtx, actionConfig, actionForm);
   helper.handleCancel(actionCtx, actionConfig, actionForm);
   helper.reset(actionCtx, actionConfig, actionForm);
   helper.populate(actionCtx, actionConfig, actionForm);
   helper.handleCancel(actionCtx, actionConfig, actionForm);
   return (false);
 }
}

On Sun, 06 Mar 2005 09:14:50 -0500, Phil Steitz <ph...@steitz.com> wrote:
> Jack,
> 
> Its best not to cross-post and when posting to one of the commons lists,
> you should start the subject line with the component name in brackets.
> 
> I can assure you that there is no "closed shop of ideas" here.  Posts
> are sometimes missed or misunderstood and sometimes the ideas don't
> resonate with others in the community. Nonresponse does not mean that
> the community is not open to new ideas.
> 
> If your questions or suggestions for improvement are about the
> implementation of [chain], it might be better to post them to
> commons-dev and/or open a Bugzilla ticket including patches showing what
> you have in mind.
> 
> Thanks!
> 
> Phil
> 
> Dakota Jack wrote:
> > I inquired why the Template Method pattern is being used with Commons
> > Chain instead of Strategy, but never got an answer.  Given that the
> > choice seems so problematic, that surprised me.  Is that (no response)
> > because there is no answer, or because it is a closed shop of ideas in
> > open source, or because there is no time to consider such a stupid
> > idea, etc.?
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org