使用 MVC 和 3 层或 N 层架构开发网站有什么区别?
使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它们几乎相同,但是在 3 层中,顶层(表示)从不直接与底层(数据持久性)通信。
在模型-视图-控制器中,理论上模型应该“通知”视图它已更改,以便视图可以更新。然而,这在大多数 Web 应用程序中通常不是问题,因为它们是无状态的。我不确定任何著名的 PHP MVC 架构是否具有直接与模型通信的视图,反之亦然,但如果没有,则可以正确地说它们实际上是 3 层。
维基百科说:
资料来源:维基百科:多层架构
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:
Source: Wikipedia: Multitier architecture