Frage

I haven't been able to find a definitive answer online, so I'm hoping that someone with experience can help answer this.

Many MVC tutorials I find online end up using the MVC architectural pattern as the architecture for the entire application. But, I have read conflicting statements from those on this site and other sites who say that MVC is just an architecture for the presentation layer of a layered architecture.

At this point I'm leaning towards the idea that it is perfectly valid as a pattern for an entire application, especially because it seems like overkill to have to design 3 separate layers for a small to medium sized application.

Which is it? Is MVC a perfectly good architectural pattern for an entire application, or is it just meant to be used as the presentation layer of a layered architecture?

War es hilfreich?

Lösung

Is MVC a perfectly good architectural pattern for an entire application, or is it just meant to be used as the presentation layer of a layered architecture?

MVC is only concerned with the user-interaction part of an application and it is a perfectly good architectural pattern for an entire application.

The MVC pattern contains 3 parts: The Controller, which is responsible for receiving user actions, the View, which is responsible for showing information to users, and the Model, which contains all the rest of the application.

If your application is not too large (which is typically the case with example programs that showcase the MVC pattern), there is no need to structure the Model further.

For a larger application, the Model part of the MVC pattern can become so large that further structure is needed to fully understand how it works. That is when you should start to apply additional architectural patterns like a layered architecture.

Andere Tipps

The MVC patterns contains three things:

  • C - Controller - Which accepts the HTTP request

  • M - Model - Which the controller uses to pass data to the view

  • V - View - HTML that is rendered for the end user

There's nothing in there for business logic, data access, authentication, or many other things.

So the answer is NO it is not a complete pattern, unless you don't need data access, business logic, authentication, or anything else.

It seems like overkill to have to design 3 separate layers for a small to medium sized application

See Why do we need so many classes in design patterns?

Lizenziert unter: CC-BY-SA mit Zuschreibung
scroll top