You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Ted Husted <hu...@apache.org> on 2006/08/03 23:01:23 UTC

Re: [s2] Convention over Configuration (was Validation)

On 8/3/06, Patrick Lightbody <fo...@opensymphony.com> wrote:
> Ted, Don: what would you guys do in the scenario Jason provided?

I think if we focus on using wildcard patterns to define the better
part of convention-over-configuration, then people can use whatever
patterns work best in a given application.

For the MailReader (just committed), I came up with three core
patterns. One for "prepare" type pages. One for "execute" type pages.
And one for simple "display" pages.

        <!-- prepare actions: Confirm/Delete, Edit, Input -->
        <!-- A "!" might be a better convention,
             but that doesn't seem to work with a button -->

        <action name="*/v*" class="mailreader2.{1}.{2}">
            <result>/pages/{1}.jsp</result>
        </action>

        <!-- execute actions: Create, Retrieve, Update, Save -->

        <action name="*/*" class="mailreader2.{1}.{2}">
            <result name="input">/pages/{1}.jsp</result>
        </action>

        <!-- display actions: Welcome, Logoff, MainMenu -->

        <action name="*" class="mailreader2.{1}">
            <result>/pages/{1}.jsp</result>
        </action>

I also needed one special-case stanza to handle a case where after
saving, the workflow returns to a caller.

        <action name="subscription/Save" class="mailreader2.subscription.Save">
            <result name="input">/pages/subscription.jsp</result>
            <result type="redirect-action">registration/vInput</result>
        </action>

So, just using wildcards, the MailReader went from 14 action elements
to 4, for a logon/logoff parent/child workflow.

To use a single-class with multiple-methods, the key change would be:

        <action name="*/*" class="mailreader2.{1}.{2}" method={2}>
            <result name="input">/pages/{1}.jsp</result>
        </action>

As mentioned, the code is committed to the head.

-Ted.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Don Brown <mr...@twdata.org>.
My take on this conversation is there are two main viewpoints:

  1. Simple convention that uses existing action mapper and wildcards
  2. Elaborate convention that uses new action mapper and probably configuration 
provider

and really, I think implementing both is worth considering. We provide a default 
struts.xml which uses the simplified convention, then with a switch, let the 
user use the more complex conventions.

Don

Patrick Lightbody wrote:
> Heh - well, that's how this was implemented in the first place. I wrote my own ActionMapper. My point is that I have seen a lot of success with a combination of ActionMapper+Convention-based-configuration, and I think we should really think about pushing this to a broader set of users.
> 
> I think Don and I agree though - implementing this stuff as wildcards would be very difficult. Our thought instead was to implement it as the recommended approach to get started, but then allow for all the standard overrides via XML that you can do today in WebWork, as well as wildcard support there. Then everyone wins.
> ---------------------------------------------------------------------
> Posted via Jive Forums
> http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=78166#78166
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Patrick Lightbody <fo...@opensymphony.com>.
Heh - well, that's how this was implemented in the first place. I wrote my own ActionMapper. My point is that I have seen a lot of success with a combination of ActionMapper+Convention-based-configuration, and I think we should really think about pushing this to a broader set of users.

I think Don and I agree though - implementing this stuff as wildcards would be very difficult. Our thought instead was to implement it as the recommended approach to get started, but then allow for all the standard overrides via XML that you can do today in WebWork, as well as wildcard support there. Then everyone wins.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=78166#78166


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Jason Carreira <fo...@opensymphony.com>.
> Ted, while I have no opinion on case, I can say that
> my comments in these threads has been driven entirely
> from real world experience. This URL:
> 
> https://struts.hostedqa.com/project/7/session/suite/li
> st
> 
> Maps, via conventions, to
> com.hostedqa.action.project.session.suite.ListAction
> 
> So there, now you have a reason for deep paths, and a
> reason why today's simple wildcards won't work :)
> 
> Patrick
> 

I think instead of making the wildcards support this, an easy to implement interface to allow custom action-mapping is in order... I'm not sure right now how easy to implement or pluggable the ActionMapper is.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=78155#78155


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Patrick Lightbody <fo...@opensymphony.com>.
Ted, while I have no opinion on case, I can say that my comments in these threads has been driven entirely from real world experience. This URL:

https://struts.hostedqa.com/project/7/session/suite/list

Maps, via conventions, to com.hostedqa.action.project.session.suite.ListAction

So there, now you have a reason for deep paths, and a reason why today's simple wildcards won't work :)

Patrick

> On 8/3/06, Patrick Lightbody
> <fo...@opensymphony.com> wrote:
> > Don and I talked in-depth about using wildcards to
> do the style of conventions I am
> >talking about, and we found that it would require a
> much more complex
> implementation of
> > wildcards. Don, can you add to that?
> 
> Why not focus on starting with conventions that are
> achievable with
> the wildcards we already have, and then expand on the
> wilcard
> capability best on actual experience, that *proves* a
> need for more
> complexity.
> 
> I would also suggest that we only add more complexity
> grudgingly and
> only when *required* to do so, not simply to placate
> an arbitrary
> convention that happens, for no particular reason, to
> be popular.
> 
> Case is a good example. Outside of the JavaBean
> design patterns, I
> believe Java itself is indifferent to case. If the
> language doesn't
> care, why should we?
> 
> -Ted.
> 
> ------------------------------------------------------
> ---------------
> To unsubscribe, e-mail:
> dev-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> dev-help@struts.apache.org
> 
>
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=78118#78118


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Ted Husted <hu...@apache.org>.
On 8/3/06, Patrick Lightbody <fo...@opensymphony.com> wrote:
> Don and I talked in-depth about using wildcards to do the style of conventions I am
>talking about, and we found that it would require a much more complex
implementation of
> wildcards. Don, can you add to that?

Why not focus on starting with conventions that are achievable with
the wildcards we already have, and then expand on the wilcard
capability best on actual experience, that *proves* a need for more
complexity.

I would also suggest that we only add more complexity grudgingly and
only when *required* to do so, not simply to placate an arbitrary
convention that happens, for no particular reason, to be popular.

Case is a good example. Outside of the JavaBean design patterns, I
believe Java itself is indifferent to case. If the language doesn't
care, why should we?

-Ted.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Jason Carreira <fo...@opensymphony.com>.
> We can be rigid and consistent in the conventions
> that we use with our
> own examples, but the nature of wildcards implies
> that people could
> adopt other conventions, whether we like it or not.
> :)
> 
> And, the nice thing about people being able to adopt
> their own
> conventions is that it takes the pressure off of us
> to try and be all
> things to all people. All we have to do is provide a
> "convention
> framework" with default settings that works for our
> example
> applications and maybe our own day-job projects too.
> If people want to
> change the defaults, then it's not our problem.

But then you get a combinatorial explosion of "best practices" and strange configurations which people will ask us to help them debug. 

Oh, and I've already got a "convention framework" where I can build whatever conventions I want.... It's called Java. Frameworks are about limiting choices along specific axis to provide structure and value.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=78103#78103


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Ted Husted <hu...@apache.org>.
On 8/3/06, Jason Carreira <fo...@opensymphony.com> wrote:
> If it looks like the stuff Don was showing before, then it's looking too complex.
>
> Either explicit configuration or easy but rigid conventions... not configurable conventions
> ;-)

We can be rigid and consistent in the conventions that we use with our
own examples, but the nature of wildcards implies that people could
adopt other conventions, whether we like it or not. :)

And, the nice thing about people being able to adopt their own
conventions is that it takes the pressure off of us to try and be all
things to all people. All we have to do is provide a "convention
framework" with default settings that works for our example
applications and maybe our own day-job projects too. If people want to
change the defaults, then it's not our problem.

-Ted.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Jason Carreira <fo...@opensymphony.com>.
If it looks like the stuff Don was showing before, then it's looking too complex. 

Either explicit configuration or easy but rigid conventions... not configurable conventions ;-)
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=78017#78017


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [s2] Convention over Configuration (was Validation)

Posted by Patrick Lightbody <fo...@opensymphony.com>.
Don and I talked in-depth about using wildcards to do the style of conventions I am talking about, and we found that it would require a much more complex implementation of wildcards. Don, can you add to that?
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=39339&messageID=77988#77988


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org