afaolek
afaolek

Reputation: 8821

Is a website MVC MVP or MVVM?

I've not really been able to differentiate between the patterns mentioned in the title.

A dynamic website has a user interface developed with basically HTML, CSS and maybe javascript (at least, that's what the user sees). The backend could be PHP or ASP (or whatever) which would be connected to a database.

I believe the database is the Model and the UI is the View. Is the backend a controller, presenter or viewmodel?

I'll appreciate an explanatory answer and, if necessary, links.

Upvotes: 0

Views: 1530

Answers (2)

tereško
tereško

Reputation: 58444

You cannot determinate which design pattern has been used for the application without access to the source code. And I get ad definite impressions, that this is what you are asking for.

Also you seem to be somewhat confused about what the are the parts of MVC and MVC-inspired design patterns:

  • Model is not the database. It is a layer (not a class or object) of application, that contains all of the domain business logic and interacts with at least one data source (which might or might not be a database).
  • The UI is maintained by presentation layer, which is mostly composed (mostly) from views and controller-like structures.

Upvotes: 5

simbo1905
simbo1905

Reputation: 6872

This microsoft msdn article WPF Apps With The Model-View-ViewModel Design Pattern describes MVVM as a microsoft customisation of Martin Fowler's Presentation Model pattern. His Passive View pattern is the MVP approach. His Supervising Controller pattern is the MVC approach. This older article takes about the evolution of such patterns. Not all languages and frameworks have good support for GUI patterns. MVVM for example was invented by Microsoft for desktop programming. Web pages typically have full page refresh rather than an event driven "desktop" programming model. It is arguable that trying to scale down the desktop patterns into a web page programming model distorts them beyond recognition.

A modern web framework that does have event driven programming model is ZK. This article Implementing event-driven GUI patterns using the ZK Java AJAX framework outlines writing the same simple screen three times using the three Martin Fowler patterns mentioned above. Everything is translated to html and javascript for the browser but the actual application screen code is running on a serverside event driven "desktop". What is the View, the Model, and the third part of the MVC/MVP/MVVM pattern is discussed in this presentation Design Patterns in ZK: Java MVVM as Model-View-Binder.

Upvotes: 0

Related Questions