-1

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.

4

2 回答 2

5

如果不访问源代码,您将无法确定应用程序使用了哪种设计模式。我得到了明确的印象,这就是你所要求的。

此外,您似乎对 MVC 和受 MVC 启发的设计模式的组成部分有些困惑:

  • 模型不是数据库。它是应用程序的一个层(不是类或对象),它包含所有领域业务逻辑并与至少一个数据源(可能是也可能不是数据库)交互。
  • UI 由表示层维护,它主要由视图和类似控制器的结构组成(大部分)。
于 2012-09-10T19:40:30.197 回答
0

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.

于 2012-12-11T23:55:31.887 回答