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

发布于 2024-09-01 21:32:26 字数 60 浏览 1 评论 0原文

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

智商已欠费 2024-09-08 21:32:26

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

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

维基百科说:

乍一看,这三个层次可能
看起来类似于MVC(模型视图
控制器)概念;然而,
从拓扑上看,它们是不同的。一个
三层结构的基本规则
架构永远不是客户端层
直接与数据通信
等级;在三层模型中所有
通讯必须通过
中间件层。从概念上讲
三层架构是线性的。
然而,MVC架构是
三角形:视图将更新发送到
控制器,控制器更新
模型和视图都会更新
直接来自模型。

资料来源:维基百科:多层架构

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文