在MVC和3层或N层架构中开发网站有什么区别? [英] What is difference of developing a website in MVC and 3-Tier or N-tier architecture?

查看:181
本文介绍了在MVC和3层或N层架构中开发网站有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

哪个更好?什么是利弊?

解决方案

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

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

维基百科说:

乍一看,这三个层次可能 看起来类似于MVC(模型视图 控制器)概念;然而, 在拓扑上它们是不同的.一种 三层基本原则 架构永远是客户层 直接与数据通信 层在三层模型中 沟通必须通过 中间件层.从概念上讲 三层架构是线性的. 但是,MVC体系结构是 三角形:视图将更新发送到 控制器,控制器更新 模型,视图就会更新 直接从模型中获取.

来源:维基百科:多层体系结构

What is difference of developing a website in MVC and 3-Tier or N-tier architecture?

Which one is better? What are pros and cons?

解决方案

They're pretty much the same, however in 3-Tier, the top level (presentation) never directly communicates with the bottom layer (data persistence).

In model-view-controller, theoretically the Model is supposed to 'notify' the View that it has changed so that the View can update. However, this is usually not an issue in most web applications because they are stateless. I'm not sure if any well-known PHP MVC architectures have Views that directly communicate with Models or vice versa, but if they don't it would be correct to say that they are in fact 3-Tier.

Wikipedia says:

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.

Source: Wikipedia: Multitier architecture

这篇关于在MVC和3层或N层架构中开发网站有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆