velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: Hashes are cool (was:FieldMethodizer() question)
Date Mon, 11 Mar 2002 18:58:04 GMT
On 3/11/02 1:24 PM, "Tim Colson" <tcolson@cisco.com> wrote:

> Geir wrote:
>> We made a decision that we weren't going to expose fields
>> directly, but 'coax' people to use setters/getters.
> 
> FWIW: In order to provide 'safe and simple' objects to the view, I had
> created several "view only" copies of objects. The getter/setters are a
> pain to maintain/synchronize between this Generally, my need is to give
> the TemplateAuthor access to the fields and keep them away from method
> calls. 
> 
> Borrowing from the FieldMethodizer thread for example : instead of
> having the template call $TrxStatistics.getValue($PAST30DAYS,$CREATES,
> $ALL) ...
> 
> I might give the template a collection of $AccountCreationStats which
> have already called stat.getValue(const,const,const) in the controller.
> More work for the Controller, but simplifies the View.
> 
> Perhaps it's my Perl background, but I've found it quite nice to use
> hashes instead of full objects in many places - it's practically self
> documenting for the Template author! :-)

This is what FieldMethodizer uses internally :)  It introspects the Class,
finds the public final stuff, and puts the values into a hash and depends
upon the   $foo.bar -> $foo.get("bar") behavior...

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
POC lives!


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message