velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Jacobson <marti...@libero.it>
Subject Re: comparing monetary value
Date Thu, 17 Oct 2002 09:16:39 GMT
Jonathan Revusky wrote:

> On Wednesday 16 October 2002 09:44 am, you wrote:
>>This thread, for all the heat it is generating, surely revolves around
>>the separation between business logic, and presentation. If you think
>>that a rigorous separation is a Good Thing, then there seems, on the
>>present evidence, to be no requirement for Velocity to handle any
>>numerical values other than integers. 
>>
> 
> Excuse me. What evidence are you referring to?


My own evidence, of course! :-)
I enforce the separation between biz logic (servlet) & presentation (vm) 
rigorously, and have come across no requirement for any arithmetic 
features at all.

> 
>>If, on the other hand, you want to
>>be able to manipulate, eg, monetary values in the template, then
>>'vanilla' Velocity won't work for you.
>>
>>My preference is for rigorous separation - but I can think of
>>circumstances where the 'quick hack' option of putting calculations, and
>>numerical comparisons in the presentation layer might make sense. (But
>>then, I'd use JSPs, to save myself learning Yet Another Programming
>>Language!)
>>
> 
> Well, I have to strongly disagree with this. The reason I would not use JSP's 
> is because I think that working with embedded Java constructs is not 
> accessible to a non-programmer. I want a separate team to control 
> presentation with absolutely minimal involvement from myself.


On further reflection, I also disagree with myself! The reason I went to 
Velocity in the first place was to escape from JSPs! However, there's 
more than one way to skin a cat, and extending the template engine to 
handle this kind of thing isn't neccessarily The Right Way.

Let's take the example you mentioned of calculating the lire equivalent 
of a Euro value: I agree that this is purely a presentation issue, but 
why do I have to do this calculation server-side? Web developers already 
use JavaScript for other purposes (eg, form data validation, fancy 
roll-overs and the like), so why not use that?
To illustrate:
<html>
<head>
	<title>Testing embedded JavaScript</title>
	<script language="JavaScript">
		function showLire(euros)
		{
			document.write(euros * 1936);
		}
	</script>
</head>
<body>
	<p>1 Euro =
	<script language="JavaScript>
		showLire(1);
	</script>
	&nbsp;Lire
	</p>
</body>
</html>

This puts the presentation logic in the presentation layer, where it 
belongs, using a presentation language that the designers already know, 
and doesn't waste server processor cycles on a problem that the client 
is perfectly capable of solving.
Velocity's minimalism is its greatest strength, as it makes it easy for 
the Web designer to learn and use: let's keep it that way! (KISS)

Martin


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