> From: Weirich, James [mailto:James.Weirich@xxxxxxx]
> In fact, I
> thought Jim Cook was saying that the constant wasn't duplicated because
> he generated the javascript constant from the value of the Java constant
> (and if he wasn't saying that, it should be a fairly easy thing to do).
That is exactly what I was saying, or at least trying to.
> Or, you could write a web service that calculates the answer (using your
> java code) and then call that service from javascript. I think that's
> what the XHtmlRequest stuff is for, but I've never done it myself.
XMLHttpRequest works nicely for heavy weight calculations and data
retrieval, but for simple calculations, the overhead doesn't seem worth it.
Do we really want a round trip to the server to do a simple multiplication?
> The key is that by providing a javascript object with behavior (e.g.
> calculate this formula) rather than a structure of data values (e.g.
> rates and hours), you decouple the rest of the code from your decisions
> about local implementation, code generation, or web services.
But for a simple calculation <input value> * <constant> what does a
javascript object provide buy us over the simple calculation?
I did think about the model object spitting out the javascript code that I
would imbed in the html page, but it seems like I am starting to put view
logic in my model. So the lesser of two evils seems to me that I use the
constant as the constant has a greater probability of being changed whereas
the simple calculation doesn't.
Hence, is this a case where use of a constant doesn't imply DP ?
|