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