Is MVC a Design Pattern or Architectural pattern
Asked Answered
G

10

132

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 ?

Guttapercha answered 8/12, 2009 at 13:0 Comment(2)
For there must be One True Answer...Baseler
according to Dave at Product Madness, MVC is a design pattern, and so is RobotLegs. :PPurge
S
74

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.

Sartre answered 8/12, 2009 at 13:5 Comment(3)
Yeah, I would say MVC is an architectural pattern for your Presentation tier.Jobe
I strongly disagree on "MVC mostly relates to the UI / interaction layer of an application". The "M"/model in MVC is the business layer, which you'd probably want to split into multiple tiers.Pecan
Yes this answer is wrong. MVC is absolutely not about UI / Interaction. You can perfectly have mvc on front end side and on back end side, at the beginning view was often just an html/js or a .jsp or a .phtml and the server define the controller and the model. Exemple JSP ( view ), JavaBeans ( Model ), Servlet ( controller ). Same concept with all the famous php framework ( symphony, zend, cake etc. ). But nowaday frontend frameworks looks like back end application and modern javascript frameworks use mvc ( html your view, controller your script, and model your js objects as entity )Bolanos
A
51

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.

Atalante answered 8/12, 2009 at 13:5 Comment(0)
S
32

Design patterns say how to write code effectively (considering Code Metrics).

A few benefits:

  1. Easily Maintainable
  2. High Re-usability
  3. Readable because of abstractions

Architectural patterns say how to utilize resources effectively.

  1. Parallel tasks execution like programmers and graphic designers can work parallel.
  2. Multiple technologies can be utilized to build a software.

In MVC, a). Views can be created using javascript templates and also html can be used b). Controllers can be written .NET framework and c). Models can be written in Java - a java service may be used that returns only json data.

While in design pattern, a pattern can't be implemented in which code can be written in multiple technologies like AdminUser class in Java, Customer class in C#, Partners class in Php and a factory pattern in Ruby :); hmmm..so easy?:)

Sesquicentennial answered 5/3, 2012 at 17:49 Comment(0)
M
12

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".

Mathur answered 1/4, 2010 at 16:10 Comment(0)
M
6

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

  • Pages 4 to 6 (Section 1.2 Design Patterns in Smalltalk MVC)
  • Pages 293 to 304 (Observer design pattern)
  • Pages 163 to 174 (Composite design pattern)
  • Pages 315 to 324 (Strategy design pattern)
  • Pages 107 to 116 (Factory Method design pattern)
  • Pages 175 to 185 (Decorator design pattern)

Eric Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading, MA, 1994.

Mercenary answered 3/11, 2017 at 20:2 Comment(1)
Thanks, all the other answers are wrong. It's absolutely not "depending of a point of view" and having dozen or hundreds votes will not make something wrong true. MVC is is not a design pattern itself, it's a way to architecture your code in 3 layers using severals design pattern that you mention. All the framework that implements MVC behind the scene use the concept of Observable, Strategy and composite pattern. The best way to understand MVC is to create your own implementation and then you will understands the design patterns behind.Bolanos
O
3

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.

Orban answered 8/12, 2009 at 13:3 Comment(0)
B
3

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

Broomrape answered 27/11, 2011 at 16:25 Comment(0)
F
2

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).

Fowler answered 8/12, 2009 at 13:9 Comment(0)
B
2

MVC always mentioned and introduced as/in presentation layer in software architecture books.

Read these books:

  1. Architecting Microsoft.NET Solutions for the Enterprise (Microsoft press)

  2. Professional ASP.NET design patterns (Wrox)

  3. Enterpise Solutions Patterns Using Microsoft.NET (Microsoft press)

  4. Patterns of Enterprise Application Architecture (Addison Wesley)

  5. A Practical Guide to Enterprise Architecture (Prentice Hall)

Broomrape answered 23/11, 2011 at 17:24 Comment(1)
why 2 answers? you could add this answer as an additional note to your first oneBuff
W
0

MVC is architecture pattern. Very clearly stated and shown at http://molecularsciences.org/zend/mvc_model_view_controller

Wace answered 15/4, 2011 at 21:46 Comment(1)
This link is now offline.Cutshall

© 2022 - 2024 — McMap. All rights reserved.