# velocity-user mailing list archives

##### Site index · List index
Message view
Top
From Jonathan Revusky <jrevu...@terra.es>
Subject Re: comparing monetary value
Date Wed, 16 Oct 2002 11:59:44 GMT
```On Wednesday 16 October 2002 09:44 am, you wrote:
> STham@thoughtworks.COM wrote:
> > Hi,
> >
> >    I believed at the moment, all numbers are treated as Integer. Anyone
> > came across this problem of manipulating with money value before?
> >
> > Example :
> >
> >   Give a certain amount has to be less than a given value.
> >
> >    if (\$someMoneyValue < 0.01) ???
> >
> > How do people normally handle money in velocity?? Thanks.
>
> 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? In my various excursions onto
this list, I observe that people are constantly running into the issue of
Velocity's limited support for numerical operations. As for this having to do
with the separation between business logic and presentation, it is not at all
clear to me that this is a cogent argument at all. Surely it is better for
the view layer to handle the correct display of floating point numbers for
various locales transparently. This is very clearly a display issue that can
and should be profitably separated away from the underlying business logic.

But what also I've observed here is that this whole "model-view
separation" mantra seems to have become a closed self-referential system of
thought.

Here are the logical steps.

1. Velocity is a tool with a feature set designed to support a "rigorous MVC
separation":

2. A user shows up on the mailing list complaining that he can't do what he
wants to do (at least without clumsy non-standard workarounds).

3. User is told basically to see point 1. above. You see, the user is not
doing "proper MVC" so Velocity does not support what he wants to do. User
should maintain a "proper MVC separation", right?

But here's the crux of it. How do we know that the user is not doing "proper
MVC"? Well, it stands to reason. If he needs a feature that Velocity does not
have, it must be because he's not doing proper MVC. Otherwise, he wouldn't

And what this boils down to is that if anybody finds Velocity to be missing
features, it is not because of any deficiency in Velocity, it is necessarily
because of a deficiency in their own app! (It's not following proper MVC
separation.)

Anyway, you get the idea, I'm sure. Surely you recognize the classic
"beg-the-question" fallacy taking form in the above?

You know, really, as a friendly suggestion, I think it would be better for
you fellows to refocus any discussion of whether a feature is desirable away
from: "Is this proper MVC?" and towards "Is this idea generally useful?"

With such a refocus, there would be much better possibilities of making some
forward progress.

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

That is precisely why I would not want a situation, where, in order to
display a distance in miles as well as kilometres (because this requires
multiplication by a non-integer) I have to become involved. I don't know how
you value your time, but I would not consider this to be a good usage of my
time, or of developer resources in general.

In fact, in terms of constant units conversion, this is quite clearly a
presentation issue. For example, in terms of straight business logic, there
is currently no difference between Euros and lire. The lire all became euros
and the lire ceased to exist. It only exists in people's minds. The same is
true of deutsche-marks, francs, and so on.

There is no reason for lire to exist in the business logic. It's all euros.
If lire are offered, it is a purely presentational convenience for people.

In any case, stepping back from this a bit, does it not really verge on the
absurd to suggest that multiplying a number by a constant is something that
should require programmer intervention?

Regards,

Jonathan Revusky
--
FreeMarker-Velocity comparison doc
http://freemarker.sourceforge.net/fmVsVel.html
Velocity->FreeMarker template conversion utility
http://freemarker.sourceforge.net/usCavalry.html

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