Integrating and taking advantage of model views

I prefer view helpers (template engine, Zend_View, etc.) … but whether or not formatting belongs in the view really depends on what type of formatting. There are instances where you need to format data in certain ways as required by the view, but there are also instances where the data is useless unless it’s formatted… What if different views require different formats of data?

While that is a theoretical argument, I don’t see it as practical - that is not to say it is or isn’t just I don’t see it yet.

I mean formatting is usually dictated by locale setting, so if you wanted currency to use comma instead of period, phone, etc. I think you would have to change the locale and model would format accordingly after changing that.

I suppose there are edge cases (like everything) such as file sizes being shown in full and then rounded to the nearest million all within the same locale. In this case however, there are calculations at play and thus business logic, so I would be returning both types via the model and unit testing to ensure the validity of the calculation performed anyways.

Cheers,
Alex

We’re talking past each other. When I’m talking about formatting I’m not talking about choosing colors, font sizes, etc.

What I am talking about is taking an address block’s components and combining them. The database needs them to be separate for reliable searching, but any view be it HTML or PDF or webservice doesn’t need to do such searching and would only need to have them in piecemeal fashion if they where presenting form controls for editing. That would constitute a whole other database view anyway since aggregation cannot be performed in any view that is to be editable.

This is a change of format. What you are talking about is what I would call a change of styling which should never occur in the model, or for that matter in the HTML.

Based on the fact that different address formats should be used depending on user locales/country shouldn’t it be the case that this address construction logic be better placed outside of a database view?