MVC是设计模式还是架构模式
According to Sun and Msdn it is a design pattern.
According to Wikipedia it is an architectural pattern
In comparison to design patterns, architectural patterns are larger in scale.
(Wikipedia - Architectural pattern)
Or it is an architectural pattern that also has a design pattern ?
Which one is true ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
MVC更多的是一种架构模式,但并不是完整的应用程序。 MVC 主要涉及应用程序的 UI/交互层。您仍然需要业务逻辑层,也许一些服务层和数据访问层。也就是说,如果您采用 n 层方法。
MVC is more of an architectural pattern, but not for complete application. MVC mostly relates to the UI / interaction layer of an application. You're still going to need business logic layer, maybe some service layer and data access layer. That is, if you're into n-tier approach.
为什么其中之一必须是真实的?
两者都可能是正确的,具体取决于观点。
如果 MVC 构成应用程序架构的基础,那么它可以是一种架构模式。
它也可以被简单地视为一种设计模式,一种适用于任何应用程序的抽象概念。
Why does one of them have to be true?
Both can be true, depending on point of view.
MVC can be an architectual pattern, if it forms the basis of the application architecture.
It can also be seen as simply a design pattern, an abstract notion that is applicable to any application.
设计模式说明如何有效地编写代码(考虑代码指标)。
一些好处:
架构模式说明了如何有效地利用资源。
Design patterns say how to write code effectively (considering Code Metrics).
A few benefits:
Architectural patterns say how to utilize resources effectively.
我知道这个问题不久前就已经得到了回答,但还没有人提到让 MVC 出名的一本书:面向模式的软件架构 (POSA),由 Buschmann 等人于 1996 年出版。尽管不像《设计模式》一书那样广泛阅读由 Gamma 等人编写的 POSA 是模式社区使用的基础书籍之一。
哦,POSA 非常清楚地将 MVC 视为一种架构模式。我的预感是,MS 和 Sun 只是草率地将每种模式称为“设计模式”。
I know that it's been answered awhile ago, but no one has yet mentioned the book that made MVC famous: Pattern-Oriented Software Architecture (POSA), by Buschmann, et al published in 1996. Though not as widely read as the Design Patterns book, by Gamma, et al, POSA is one of the foundational books used by the patterns community.
Oh, and POSA very clearly identifies MVC as an architectural pattern. My hunch is that MS and Sun are just being sloppy and calling every pattern a "design pattern".
模型/视图/控制器 (MVC) 三元组内的设计模式包括但可能不限于:
观察者,解耦对象,以便对一个(模型)的更改可以影响任何对象。数量其他(视图),而不需要更改的对象(模型)知道其他对象(视图)的详细信息。
复合,它让我们可以像对待其中的单个对象(视图组件)一样对待组对象(复合视图)。
策略,其中视图使用 Controller 子类的实例来实现特定的响应策略;要实现不同的策略,只需用不同类型的控制器替换该实例即可。
工厂方法,指定视图的默认控制器类。
装饰器,向视图添加滚动。
参考
Eric Gamma、Richard Helm、Ralph Johnson 和 John Vlissides。 设计模式:可重用的面向对象软件的元素。艾迪生韦斯利,雷丁,马萨诸塞州,1994 年。
The design patterns inside the Model/View/Controller (MVC) triad of classes include and may not be limited to:
Observer, decoupling objects so that changes to one (the model) can affect any number of others (the views) without requiring the changed object (the model) to know details of the others (the views).
Composite, which lets us treat a group object (a composite view) just like we treat one of its individual objects (view components).
Strategy, where a view uses an instance of a Controller subclass to implement a particular response strategy; to implement a different strategy, simply replace the instance with a different kind of controller.
Factory Method, specifying the default controller class for a view.
Decorator, adding scrolling to a view.
Reference
Eric Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, MA, 1994.
我认为两者都是正确的。如果您正在像 Ruby on Rails 这样的框架中查看 MVC 的特定实例化,那么该实例化更像是一种设计模式。如果您将 MVC 视为一个一般概念,那么它更像是一种架构模式。
I think both are true. If you're looking at a particular instantiation of MVC in a framework like Ruby on Rails, that instantiation is more of a design pattern. If you look at MVC as a general concept, it's more of an architectural pattern.
根据 Martin Fowler 的说法,它们是 GUI 架构: Martin Fowler-GUI 架构
这取决于应用程序的大小,因为它只影响与 GUI 相关的类,在小型应用程序(主要是 GUI)中,它可以被视为一种架构模式,而在大型应用程序中,它只是一种应用于 GUI 代码的设计模式(可以是应用程序代码的 10%)。
And according to Martin Fowler they are GUI architectures: Martin Fowler-GUI architectures
It depends on the size of the application, as it only affects GUI related classes, in a small one (mostly GUI) it could be considered an architectural pattern whereas in a huge one it would just be a design pattern that you apply to the GUI code (could be 10% of the apps code).
MVC 在软件架构书籍中经常提到和介绍 as/in 表示层。
阅读这些书籍:
为企业构建 Microsoft.NET 解决方案( Microsoft Press)
专业 ASP.NET 设计模式 (Wrox)< /p>
< a href="https://rads.stackoverflow.com/amzn/click/com/0735618399" rel="nofollow noreferrer">使用 Microsoft.NET 的企业解决方案模式(微软出版社)
企业应用程序架构模式 (Addison Wesley)
企业架构实用指南 (Prentice Hall)
MVC always mentioned and introduced as/in presentation layer in software architecture books.
Read these books:
Architecting Microsoft.NET Solutions for the Enterprise (Microsoft press)
Professional ASP.NET design patterns (Wrox)
Enterpise Solutions Patterns Using Microsoft.NET (Microsoft press)
Patterns of Enterprise Application Architecture (Addison Wesley)
A Practical Guide to Enterprise Architecture (Prentice Hall)
如果你把十个软件架构师放在一个房间里,让他们讨论什么是模型-视图-控制器模式,你最终会得到十二种不同的意见。 ……一些纯粹主义者不可避免地会对我所说的“MVC”产生疑虑。请随意在此网页底部的留言板上留下激烈的评论。我很乐意对 MVC 的含义抱有不同的看法,但请记住我不在乎。
乔什·史密斯
If you put ten software architects into a room and have them discuss what the Model-View-Controller pattern is, you will end up with twelve different opinions. … Some of the purists out there will inevitably have qualms with what I refer to as “MVC”. Feel free to leave a flaming comment on the message board at the bottom of this Web page. I will gladly entertain different perspectives on what MVC means, but keep in mind that I do not care.
Josh Smith
MVC是架构模式。非常清楚地说明并显示在 http://molecularsciences.org/zend/mvc_model_view_controller
MVC is architecture pattern. Very clearly stated and shown at http://molecularsciences.org/zend/mvc_model_view_controller