Vita Rara: A Life Uncommon

Web Page Data Models: Where do they go?

Categories: | |

You have a web page that has tabular data that doesn't represent simple rows from a database. It's a field from this table, one from that, one from four joins away. It's a little bit of data from all over your data model, but the client wants it on the screen. What do you do?

In the past I used to just a SQL result set and turn it into a Collection. Nice and neat. Iterate over the collection and put the stuff onto the screen. Simple enough, back then. Now I'd like to have better control over my models, and have them be full classes, with strong typing, setters and getters, etc.

The question is where should that class reside? Is it part of the data model? Is it a business object? It's really a presentation model. It only exists to make presentation of data easier. In essence it's like a report, or an element of a report. So, where should it live?

One part of me says it out to live in a package in my presentation tier. Problem with that is I don't want my business layer to know anything about my presentation layer, and I don't want my data layer know anything about the two layers above it.

So, because of that by my rules, because this data is going to be retrieved from a class in my data layer, it ought to also be in the data layer. Problem is that doesn't feel right either. My data layer strictly consists of entity objects and data access objects to access those entities.

So, where do they go?