You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Michael Salmon <ms...@collab.net> on 2001/07/12 01:07:30 UTC

VMContext diff

hi folks,
I added extra methods to VMContext to automatically convert native types
being put into a context to their Object. This saves casting on the
developer and is something I think is reasonable to add. 
diff attached.

ms-

RE: VMContext diff

Posted by Paulo Gaspar <pa...@krankikom.de>.
To me, it still looks like something that is better in a "tool" class.

Have fun,
Paulo Gaspar

> -----Original Message-----
> From: Michael Salmon [mailto:ms@collab.net]
> Sent: Friday, July 13, 2001 8:04 PM
> 
> 
> On Fri, Jul 13, 2001 at 05:51:10AM -0400, Geir Magnusson Jr. wrote:
> > Jon Stevens wrote:
> > > 
> > > on 7/11/01 8:44 PM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> > > 
> > > > I dunno ...  I run across this a lot, and quite frankly it doesn't
> > > > bother me to just do a new <FOO>.
> > > >
> > > > The problem that I see is that this makes the API for 
> VelocityContext
> > > > different than that of Context - so if you get into the 
> [bad] habit of
> > > > using the helper methods instead of just using something like
> > > >
> > > > context.put( "foo", new Integer(2));
> > > >
> > > > then when you move that code into a more generic situation 
> where you are
> > > > passed a Context rather than a VelocityContext, all will 
> break. (Don't
> > > > even suggest this for the Context interface...:)
> > > >
> > > > geir
> > > 
> > > More detail needed:
> > > 
> > >     Why exactly is it bad?
> > > 
> > > -jon
> > 
> > Why is adding to the Context interface bad?  Because then every
> > implementation of Context then has to support those methods.  It takes
> > the interface from 5 methods to 13 methods, with no real functional
> > addition other than you can avoid typing 'new <CLASS>( arg )' when you
> > want to convert a primitive to an Object.
> > 
> > It's a nice convenience, but is that worth it?
> 
> I wasnt suggesting adding methods to the interface, just the
> implementation. If I was suggesting the former I would have put that in
> the diff ;-)
>  
> > geir
> > 
> > 
> > 
> > -- 
> > Geir Magnusson Jr.                           geirm@optonline.net
> > System and Software Consulting
> > Developing for the web?  See http://jakarta.apache.org/velocity/
> > You have a genius for suggesting things I've come a cropper with!
> 

Re: VMContext diff

Posted by Michael Salmon <ms...@collab.net>.
On Fri, Jul 13, 2001 at 05:51:10AM -0400, Geir Magnusson Jr. wrote:
> Jon Stevens wrote:
> > 
> > on 7/11/01 8:44 PM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> > 
> > > I dunno ...  I run across this a lot, and quite frankly it doesn't
> > > bother me to just do a new <FOO>.
> > >
> > > The problem that I see is that this makes the API for VelocityContext
> > > different than that of Context - so if you get into the [bad] habit of
> > > using the helper methods instead of just using something like
> > >
> > > context.put( "foo", new Integer(2));
> > >
> > > then when you move that code into a more generic situation where you are
> > > passed a Context rather than a VelocityContext, all will break. (Don't
> > > even suggest this for the Context interface...:)
> > >
> > > geir
> > 
> > More detail needed:
> > 
> >     Why exactly is it bad?
> > 
> > -jon
> 
> Why is adding to the Context interface bad?  Because then every
> implementation of Context then has to support those methods.  It takes
> the interface from 5 methods to 13 methods, with no real functional
> addition other than you can avoid typing 'new <CLASS>( arg )' when you
> want to convert a primitive to an Object.
> 
> It's a nice convenience, but is that worth it?

I wasnt suggesting adding methods to the interface, just the
implementation. If I was suggesting the former I would have put that in
the diff ;-)
 
> geir
> 
> 
> 
> -- 
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a cropper with!

Re: VMContext diff

Posted by Jason van Zyl <jv...@apache.org>.
On 7/13/01 5:51 AM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:

> Jon Stevens wrote:
>> 
>> on 7/11/01 8:44 PM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:
>> 
>>> I dunno ...  I run across this a lot, and quite frankly it doesn't
>>> bother me to just do a new <FOO>.
>>> 
>>> The problem that I see is that this makes the API for VelocityContext
>>> different than that of Context - so if you get into the [bad] habit of
>>> using the helper methods instead of just using something like
>>> 
>>> context.put( "foo", new Integer(2));
>>> 
>>> then when you move that code into a more generic situation where you are
>>> passed a Context rather than a VelocityContext, all will break. (Don't
>>> even suggest this for the Context interface...:)
>>> 
>>> geir
>> 
>> More detail needed:
>> 
>>     Why exactly is it bad?
>> 
>> -jon
> 
> Why is adding to the Context interface bad?  Because then every
> implementation of Context then has to support those methods.  It takes
> the interface from 5 methods to 13 methods, with no real functional
> addition other than you can avoid typing 'new <CLASS>( arg )' when you
> want to convert a primitive to an Object.
> 
> It's a nice convenience, but is that worth it?

No. I don't think so.
 
> geir
> 
> 

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



Re: VMContext diff

Posted by Jon Stevens <jo...@latchkey.com>.
on 7/13/01 2:51 AM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:

> Why is adding to the Context interface bad?  Because then every
> implementation of Context then has to support those methods.  It takes
> the interface from 5 methods to 13 methods, with no real functional
> addition other than you can avoid typing 'new <CLASS>( arg )' when you
> want to convert a primitive to an Object.
> 
> It's a nice convenience, but is that worth it?
> 
> geir

Convenience for the end user and developer is a good thing.

My guess is that few people implement their own Context object's.

-jon


Re: VMContext diff

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jon Stevens wrote:
> 
> on 7/11/01 8:44 PM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> 
> > I dunno ...  I run across this a lot, and quite frankly it doesn't
> > bother me to just do a new <FOO>.
> >
> > The problem that I see is that this makes the API for VelocityContext
> > different than that of Context - so if you get into the [bad] habit of
> > using the helper methods instead of just using something like
> >
> > context.put( "foo", new Integer(2));
> >
> > then when you move that code into a more generic situation where you are
> > passed a Context rather than a VelocityContext, all will break. (Don't
> > even suggest this for the Context interface...:)
> >
> > geir
> 
> More detail needed:
> 
>     Why exactly is it bad?
> 
> -jon

Why is adding to the Context interface bad?  Because then every
implementation of Context then has to support those methods.  It takes
the interface from 5 methods to 13 methods, with no real functional
addition other than you can avoid typing 'new <CLASS>( arg )' when you
want to convert a primitive to an Object.

It's a nice convenience, but is that worth it?

geir



-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: VMContext diff

Posted by Jon Stevens <jo...@latchkey.com>.
on 7/11/01 8:44 PM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:

> I dunno ...  I run across this a lot, and quite frankly it doesn't
> bother me to just do a new <FOO>.
> 
> The problem that I see is that this makes the API for VelocityContext
> different than that of Context - so if you get into the [bad] habit of
> using the helper methods instead of just using something like
> 
> context.put( "foo", new Integer(2));
> 
> then when you move that code into a more generic situation where you are
> passed a Context rather than a VelocityContext, all will break. (Don't
> even suggest this for the Context interface...:)
> 
> geir

More detail needed:

    Why exactly is it bad?

-jon


Re: VMContext diff

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Michael Salmon wrote:
> 
> hi folks,
> I added extra methods to VMContext to automatically convert native types
> being put into a context to their Object. This saves casting on the
> developer and is something I think is reasonable to add.
> diff attached.
> 

I dunno ...  I run across this a lot, and quite frankly it doesn't
bother me to just do a new <FOO>.

The problem that I see is that this makes the API for VelocityContext
different than that of Context - so if you get into the [bad] habit of
using the helper methods instead of just using something like

context.put( "foo", new Integer(2));

then when you move that code into a more generic situation where you are
passed a Context rather than a VelocityContext, all will break. (Don't
even suggest this for the Context interface...:)

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!