|
From: Michael Y. <sp...@on...> - 2004-01-02 17:56:24
|
I totally agree with you David.
I have similar sentiments regarding methods being final in Spring
Framework. I am very happy with pretty much everything in Spring
Framework except this issue, and I hope the Spring Framework
developers can consider this issue seriously.
Simply put, I don't want my favorite framework to tie my hands,
and prevent me from convincing others to adopt it.
/Michael.
On Thursday, Jan-01-2004 17:24 PM (PST) fog...@ya... (David Heimann) wrote:
> Ken and developers,
>
> I have a business rule in my system that all the data be
> stored in upper case in the database. This sugests the
> following design:
>
> 1)This is a business rule and so should be in the model
> layer rather than the presentation layer
>
> 2)The code to upper case the data should be centralized.
> Requiring each developer to upper case the data before
> calling the execute or update methods duplicates code and
> is error prone. (the PetClinic sample has around 12
> execute or update calls, each of which would need to be
> prefaced by upper casing code)
>
> 3)This suggests a design where I extend SqlUpdate and
> SqlQuery and override the SqlUpdate.update and
> SqlQuery.execute methods, for example
>
> public abstract SqlQueryUpper extends SqlQuery
> {
> public List execute(Object[] parameters, Map context)
> throws DataAccessException {
> //upper case string parameters
> for(int i = 0;i<parameters.length;i++)
> {
> Object p = parameters[i];
> if(p instanceof java.lang.String)
> {
> parameters[i] = p.toUpper();
> }
> }
> return super.execute(parameters, context);
> }
> }
>
> Of course, I could create my own method with a different
> name such as
> ...
> public List executeUpper(Object[] parameters, Map context)
> throws DataAccessException
> {
> (same as above)
> }
>
> But if I do that, then I
> 1)Still have the original SqlQuery.execute method out
> there which no one should use.
> 2)Do not have all the other signatures available such as
> SqlQuery.execute(int), SqlQuery.execute(String) etc because
> they all still go through the original execute method.
>
> Finally, my problem is an example of something not included
> or anticipated by the developers of the Spring Framework.
> There is no built in Spring 'auto-upper' option nor should
> there be. Putting final on methods stops me from adding it
> myself, making the framework unextendable in this area.
> IMHO final methods should be few and far between in an
> extensible framework and I do not think they are called for
> here.
>
> Sincerely,
>
> David Heimann
>
> >David,
> >
> > I don't understand why you think it would be nice to
> ***override*** it.
> > The execute method does all the IOC hard stuff for you.
> If you override
> > it, you have to do this yourself, adding unnecessary
> duplication. That's
> > why it's final. The same goes for SqlUpdate.update. In
> your example, why
> > not simply manipulate the parameters to your heart's
> content before
> > passing them to the execute method ?
> >
> > Ken
> >
> > Heimann, David X - San Mateo, CA wrote:
> >
> > > Developers,
> > >
> > > Could you change
> > >
> > > *public** final* List execute(*final* Object[]
> parameters, Map context)
> > > {
> > > ...
> > > }
> > >
> > > in org.springframework.jdbc.object.SqlQuery to not be
> final ? It
> > > would be nice to overload it, for example to change all
> parameters to
> > > upper case before executing. The similar update method
> in SqlUpdate
> > > is not final. Why be final at all ?
> > >
> > > David Heimann
> > >
>
>
> __________________________________
> Do you Yahoo!?
> Find out what made the Top Yahoo! Searches of 2003
> http://search.yahoo.com/top2003
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
> Free Linux Tutorials. Learn everything from the bash shell to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|