0
votes

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.

2
I'm voting to close this question as off-topic because questions about software architecture belong on programmers.stackexchange.com - Rob
@Rob when referring other sites, it is often helpful to point that cross-posting is frowned upon - gnat
@gnat This question will probably get moved by a mod but, if he cross posts, this will get deleted. - Rob
There are many questions on stackoverflow about software architecture. I have read too many before posting here. Also, i am not sure about the down vote too. Could the down voter elaborate ? - ykh
@ykh They just didn't get caught. It's not a crime. Just delete this one and ask it on programmers. That's what it's there for. - Rob

2 Answers

0
votes
  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%.
0
votes

Is the relation in this manner right ?

My answer is that depends on your project scale and team size, But let me explain you my projects architecture.

  • MVC: A presentation layer, It is the startup project of the application.
  • Common: This is a class library which contains a set of core classes, such as helpers, base classes, ... This project is referenced to all other projects.
  • Repositories: For reading from and writing to a database, I've created a project and named it repositories. This project is a combination of repository and the Unit of Work pattern. Implementing these patterns can help insulate your application from changes in the data store.
  • Test: Unit tests are written in this project.

Hope this will help you.