Women in Technology

Hear us Roar



Article:
  A Look at Commons Chain, Part 1
Subject:   Playing to Weakness
Date:   2005-03-03 07:43:53
From:   dakotajack


I think Bill Siggelkow hits the nail on the head in saying that the Template Method involves tight coupling and less flexibility and that this handicap is mitigated by Commons Chain allowing the algorithm to be defined through a configuration file interpreted at runtime. Indeed, if you have followed the attempt to use this "framework" as a substitute for the RequestProcessor of Struts v1.2.6 in Struts v1.3, you see how the limited this mitigation is.


Why in the world Commons Chain and Struts do not take advantage of the inherent benefits of the Strategy pattern instead of the Template Method pattern is a real mystery. Wouldn't the following be so much better it would just "pop out" as vastly inferior? I suggested this, but got no response with the open source (free) but closed community [a community that does not know the difference between a tickle and an itch -- ///;-)] building Struts:



public class DoSomething implements Command {
private Helper helper;


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


public boolean execute(Context context)
throws Exception {
// Have helper do stuff
return (false);
}
}


I would be interested what others think of this alternative.


Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Bill Siggelkow photo Playing to Weakness
    2005-03-03 11:25:49  Bill Siggelkow | O'Reilly Author [View]

    IMO the Template Method and Strategy pattern solve different problems. Template method defines the steps of an algorithm; Strategy turns an algorithm defined in a method into a class. The Struts RequestProcessor is, in fact, an implementation of the Strategy pattern -- it defines the strategy for request processing used by the Struts ActionServlet. To me, Chain addresses the issue of coupling quite nicely. Regarding the Struts community, I have found them this group to be intelligent, friendly and open.

    • Playing to Weakness
      2005-06-01 03:34:34  isto.nikula [View]

      There is also a middle way approach: using template method and strategy together. Instead of using inheritance and calls to abstract methods in the template method, the method implementations could be provided via a strategy (interface).