Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Model–view–controller
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===View=== Any representation of information such as a [[chart]], diagram or table. Multiple views of the same information are possible, such as a bar chart for management and a tabular view for [[accountant]]s. In Smalltalk-80, a view is just a visual representation of a model, and does not handle user input.<ref>{{cite book |last1=LaLonde |first1=Wilf R. |last2=Pugh |first2=John R. |date=1991 |title=Inside Smalltalk |url=https://books.google.com/books?id=RRkiAQAAIAAJ |location=U.S.A. |publisher=Prentice-Hall Inc. |isbn=0-13-467309-3 |page=8 |quote=The view is responsible for providing a visual representation of the object.}}</ref> With WebObjects, a view represents a complete user interface element such as a menu or button, and does receive input from the user.<ref>{{cite book |author=<!--Staff writer(s); no by-line.--> |date=May 2001 |title=WebObjects System Overview |url=https://developer.apple.com/library/archive/documentation/LegacyTechnologies/WebObjects/WebObjects_5/WebObjectsOverview/WebObjectsOverview.pdf |location=Cupertino, CA |publisher=Apple Computer, Inc. |page=28 |quote=View objects represent things visible on the user interface (windows, for example, or buttons).}}</ref> In both Smalltalk-80 and WebObjects, however, views are meant to be general-purpose and [[Composability|composable]].<ref>{{cite book |last1=LaLonde |first1=Wilf R. |last2=Pugh |first2=John R. |date=1991 |title=Inside Smalltalk |url=https://books.google.com/books?id=RRkiAQAAIAAJ |location=U.S.A. |publisher=Prentice-Hall Inc. |isbn=0-13-467309-3 |page=8 |quote=[MVC] permits views to be used as parts for assembly into larger units; new kinds of views can be constructed using existing views as subviews.}}</ref><ref>{{cite book |author=<!--Staff writer(s); no by-line.--> |date=May 2001 |title=WebObjects System Overview |url=https://developer.apple.com/library/archive/documentation/LegacyTechnologies/WebObjects/WebObjects_5/WebObjectsOverview/WebObjectsOverview.pdf |location=Cupertino, CA |publisher=Apple Computer, Inc. |page=28 |quote=View objects tend to be very reusable and so provide consistency between applications.}}</ref> With Rails and Django, the role of the view is played by [[HTML]] templates, so in their scheme a view specifies an in-browser user interface rather than representing a user interface widget directly.<ref>{{cite web |url=https://guides.rubyonrails.org/action_view_overview.html |title=Action View Overview|author=<!--Not stated--> |date=<!--Not stated--> |website=Rails Guides |access-date=October 27, 2022 |quote=Action View templates are written using embedded Ruby in tags mingled with HTML.}}</ref><ref>{{cite web |url=https://docs.djangoproject.com/en/4.1/topics/templates/ |title=Templates |author=<!--Not stated--> |date=<!--Not stated--> |website=Django Documentation |access-date=October 27, 2022 |quote= A template contains the static parts of the desired HTML output as well as some special syntax describing how dynamic content will be inserted.}}</ref> (Django opts to call this kind of object a "template" in light of this.<ref>{{cite web |url=https://docs.djangoproject.com/en/4.0/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names |title=Django FAQ: Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names? |access-date=October 27, 2022}}</ref>) This approach puts relatively less emphasis on small, composable views; a typical Rails view has a [[Cardinality (data modeling)|one-to-one relationship]] with a controller action.<ref>{{cite web |url=https://guides.rubyonrails.org/action_view_overview.html |title=Action View Overview |author=<!--Not stated--> |date=<!--Not stated--> |website=Rails Guides |access-date=October 27, 2022 |quote=Typically, the views share their name with the associated controller action...}}</ref> Smalltalk-80 views communicate with both a model and a controller,<ref>{{cite book |last1=LaLonde |first1=Wilf R. |last2=Pugh |first2=John R. |date=1991 |title=Inside Smalltalk |url=https://books.google.com/books?id=RRkiAQAAIAAJ |location=U.S.A. |publisher=Prentice-Hall Inc. |isbn=0-13-467309-3 |page=9 |quote=...the view knows explicitly about the model and the controller.}}</ref> whereas with WebObjects, a view talks only to a controller, which then talks to a model.<ref>{{cite book |author=<!--Staff writer(s); no by-line.--> |date=May 2001 |title=WebObjects System Overview |url=https://developer.apple.com/library/archive/documentation/LegacyTechnologies/WebObjects/WebObjects_5/WebObjectsOverview/WebObjectsOverview.pdf |location=Cupertino, CA |publisher=Apple Computer, Inc. |page=28 |quote=Acting as a mediator between Model objects and View objects in an application is a Controller object.}}</ref> With Rails and Django, a view/template is used by a controller/view when preparing a response to the client.<ref>{{cite web |url=https://guides.rubyonrails.org/action_view_overview.html |title=Action View Overview |author=<!--Not stated--> |date=<!--Not stated--> |website=Rails Guides |access-date=October 27, 2022 |quote=In Rails, web requests are handled by action controller and action view. Typically, action controller is concerned with communicating with the database and performing CRUD actions where necessary. Action View is then responsible for compiling the response.}}</ref><ref name="djangoviewtemplfaq">{{cite web |url=https://docs.djangoproject.com/en/4.0/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names |title=Django FAQ: Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names? |access-date=October 27, 2022 |quote=In Django, a 'view' describes which data is presented, but a view normally delegates to a template, which describes how the data is presented.}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)