php - 在 MVC 和 3 层或 N 层架构中开发网站有什么区别?

标签 php model-view-controller n-tier-architecture 3-tier

用 MVC 和 3 层或 N 层架构开发网站有什么区别?

哪个更好?有什么优点和缺点?

最佳答案

它们几乎相同,但是在 3 层中,顶层(表示)从不直接与底层(数据持久性)通信。

在模型- View - Controller 中,理论上模型应该“通知” View 它已更改,以便 View 可以更新。但是,这在大多数 Web 应用程序中通常不是问题,因为它们是无状态的。我不确定是否有任何著名的 PHP MVC 架构具有直接与模型通信的 View ,反之亦然,但如果没有,那么说它们实际上是 3 层是正确的。

维基百科说:

At first glance, the three tiers may seem similar to the MVC (Model View Controller) concept; however, topologically they are different. A fundamental rule in a three-tier architecture is the client tier never communicates directly with the data tier; in a three-tier model all communication must pass through the middleware tier. Conceptually the three-tier architecture is linear. However, the MVC architecture is triangular: the View sends updates to the Controller, the Controller updates the Model, and the View gets updated directly from the Model.

来源:Wikipedia: Multitier architecture

关于php - 在 MVC 和 3 层或 N 层架构中开发网站有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2843311/

相关文章:

同一解决方案中的 ASP.Net Web 和 WCF 项目

asp.net-mvc - ASP.NET MVC - 服务层 - 业务层 - 数据层 (EF) - SQL DB::数据传输?

php - Yii2 ActiveQuery 一列不等于另一列

php - 什么是php中的实体类

PHP 检查字符串是否包含不带 http 的 url ://

javascript - 使用 knockout.js 构建 Accordion

c# - WCF 之外的项目中的 DataContract

php - 在 mb_encode_numericentity() 中更好地解释 $convmap

asp.net-mvc - 有什么办法可以让 table 变宽吗?也许 bootstrap 在某处设置了 max-witdh ?

model-view-controller - 与模型 View 相比, Model View Controller (MVC)有什么优势?