velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Colson" <tcol...@cisco.com>
Subject RE: controller logic (was: discarding method return..)
Date Mon, 04 Nov 2002 15:02:45 GMT
Bob -

> Sorry for being pedantic here, but if you're calling a method and
> ignore its return value in a template, then you're just wanting
> the side-effects of the method call?  I'd consider that to probably
> be a Bad Programming Practice.  That logic is probably better-suited
> for the Controller end of things, and [not] in the View.

Certainly a good point, thanks for correcting me.

Not that anyone cares, but when I wrap stuff, it's usually to prevent an
accidental method access like $myhashmap.clear(), or perhaps
myAppScopeHash.put("FOO", "BAR") or other nasties in the View. (I did
say I'm paranoid, didn't I? ;-)

I take a simpleton approach to the templates - 99% of mine consist of
$thing, #foreach ($thing in $LIST_OF_THINGS), #if ($thingIsTrue), #macro
(coolthing $thing) - i.e. mostly read-only operations because the
controller code has done all the heavy-lifting. 

Say - off this topic, but wouldn't it be cool if a template editor
application could do inline introspection? 

Ex. type "$" and up pops a list of items in the context, select
"myhashmap" from that list, type "." and up pops a list of possible
methods & keys? 

Jumping way way way ahead...if that existed, then for my stuff, I'd want
to avoid placing a full blown HashMap into the context, and instead use
a simpler wrapper that only had...oh... get() and maybe keyset()
available. Almost brings to mind similar aspects of 'security by
obscurity' problems. :-)

Cheers!
Tim


--
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