Search code examples
model-view-controllern-tier-architecture

MVC With N-Tier Architecture


I have been jumping between articles and questions but i can't seem to find the information i want.

When i started learning about MVC, tutorials and articles pointed out that:
*Models: is where you business logic goes
*Controller: is where data-access and handling request/respond happens.

I have been working with MVC for a while now and I wanted to migrate an old simple project to MVC. In the project i have a business and data access layers. After reading about N-Tier MVC architecture, my understanding changed.

The model in which i usually presumed to be the business domain has now changed to be more of a presentation depending on views. Its true that models reflects the business entities but it acts as another layer over it.

So my question here is the following: Assume that i have an MVC project and i have another two projects, business and data-access. Is the relation in this manner right ?

*A model, will mostly have the same properties as in its corresponding business entity.
*The controller will call the DataAccess-Layer to retrieve data, the data will be returned as business object which will be mapped into a model and then returned into a view.


Solution

    1. Model not always corresponds to business entities. Because models in MVC used to reflect entities that will be sent to view. So they may be little bit sipmlier than domain business entities. It is correct that your domain model will be mapped to mvc model.
    2. Second statement I agree 100%.