Hi, I'm strating out web programming in Java and I want to know the best practices. I'm wondering where should my computations reside in let's say a Java MVC app or a Struts apps?
+4
A:
It depends on the kind of computation. Most computations belong in the model, because most computations are tied to the data contained in the model.
But sometimes you need to compute something in a view (say, for example, you need to determine if there are enough items in a list to justify flipping to an alternate page format).
And sometimes they belong in the controller (maybe you need to determine which view to transition to based on controller-centric factors).
The real answer is, computations belong near the data they are tied to. Don't sum up account totals in the view, and don't compute font sizes in the model. Ommm.
MarkusQ
2009-03-22 05:41:42
Wow thanks! I've learned something new :)
ajushi
2009-03-22 06:25:23
BTW, what does Ommm mean?
ajushi
2009-03-22 06:27:37
So shiuld I put coputations in beans?
ajushi
2009-03-22 07:34:51