How many tiers should my models have in a DB driven web app?
Posted
by
Hanno Fietz
on Programmers
See other posts from Programmers
or by Hanno Fietz
Published on 2011-11-24T20:42:26Z
Indexed on
2011/11/25
2:17 UTC
Read the original article
Hit count: 262
design
In my experience, the "Model" in MVC is often not really a single layer. I would regularly have "backend" models and "frontend" models, where the backend ones would have properties that I want to hide from the UI code, and the frontend ones have derived or composite properties which are more meaningful in the context of the UI.
Recently, I have started to introduce a third layer in between when database normalization created tables that did not really match the conceptual domain objects anymore. In those projects I have model classes that are equivalent with the DB structure, these become components of objects that represent the domain model, and finally these are filtered and amended for displaying information to the user.
Are there patterns or guidelines for how, when and why to organize the data model across application layers?
© Programmers or respective owner