Questions tagged [model-view-controller]

Model–View–Controller (MVC) is an architectural pattern, introduced in mid 1970-s in PARC into how to compose software interfacing also with user-interactions. For Microsoft ASP.NET MVC, please use [] or [] tag instead. For Spring MVC, please use [spring-mvc] tag instead.

Model–View–Controller (MVC) is an architectural pattern used in software engineering, since Palo Alto Research Centre released one such in mid 1970-ies, designed in Smalltalk-79 language.

The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing, portability and maintenance of each (separation of concerns).

Image which demonstrates typical collaboration of the MVC components:



The analogy

MVC can be metaphorically related to a TV. You have various channels, with different information on them supplied by your cable provider (the model). The TV screen displays these channels to you (the view). You pressing the buttons on the remote controls affects what you see and how you see it (the controller).

33635 questions
10 answers

Spring Test & Security: How to mock authentication?

I was trying to figure out how to unit test if my the URLs of my controllers are properly secured. Just in case someone changes things around and accidentally removes security settings. My controller method looks like…
Martin Becker
  • 3,331
  • 3
  • 22
  • 25
1 answer

DTO and DAO concepts and MVC

Why do we use DTO and DAO, and when should we use them. I am developing a GUI Java software to do with inserting, editing, deleting data. But I am struggling to distinguish between DTO/DAO and Model, View, Controller (MVC) structure? Are they…
  • 2,942
  • 5
  • 28
  • 32
5 answers

Show pop-ups the most elegant way

I have this AngularJS app. Everything works just fine. Now I need to show different pop-ups when specific conditions become true, and I was wondering what would be the best way to proceed. Currently I’m evaluating two options, but I’m absolutely…
  • 5,961
  • 6
  • 33
  • 52
12 answers

Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported for @RequestBody MultiValueMap

Based on the answer for problem with x-www-form-urlencoded with Spring @Controller I have written the below @Controller method @RequestMapping(value = "/{email}/authenticate", method = RequestMethod.POST , produces =…
Somasundaram Sekar
  • 5,244
  • 6
  • 43
  • 85
12 answers

Should sorting logic be placed in the model, the view, or the controller?

I have a drop down list that displays values from a table to the end user. I would like to have these values be sorted alphabetically. According to proper MVC design, at what layer should I place my sorting logic: the model, the view, or the…
Ryan Kohn
  • 13,079
  • 14
  • 56
  • 81
10 answers

Rails Model, View, Controller, and Helper: what goes where?

In Ruby on Rails Development (or MVC in general), what quick rule should I follow as to where to put logic. Please answer in the affirmative - With Do put this here, rather than Don't put that there.
  • 12,190
  • 11
  • 41
  • 49
7 answers

Limiting number of displayed results when using ngRepeat

I find the AngularJS tutorials hard to understand; this one is walking me through building an app that displays phones. I’m on step 5 and I thought as an experiment I’d try to allow users to specify how many they’d like to be shown. The view looks…
Captain Stack
  • 3,572
  • 5
  • 31
  • 56
12 answers

MVC Vs n-tier architecture

I was wondering what exactly is the difference between MVC(which is an architectural pattern) and an n-tier architecture for an application. I searched for it but couldn't find a simple explanation. May be I am a bit naive on MVC concepts, so if…
  • 29,828
  • 40
  • 114
  • 128
10 answers

How to render and append sub-views in Backbone.js

I have a nested-View setup which can get somewhat deep in my application. There are a bunch of ways I could think of initializing, rendering and appending the sub-views, but I'm wondering what common practice is. Here are a couple I've thought…
Ian Storm Taylor
  • 8,520
  • 12
  • 55
  • 72
7 answers

How to include view/partial specific styling in AngularJS?

What is the proper/accepted way to use separate stylesheets for the various views my application uses? Currently I'm placing a link element in the view/partial's html at the top but I've been told this is bad practice even though all modern browsers…
  • 4,486
  • 8
  • 33
  • 39
30 answers

Is there a JavaScript MVC (micro-)framework?

Are there any client-side JavaScript MVC (micro-)frameworks? I have a rather complicated HTML form, and it would benefit from the MVC pattern. I imagine a good solution would provide the following: Model and View update the Controller when values…
  • 19,211
  • 12
  • 66
  • 82
2 answers

GUI not working after rewriting to MVC

I'm practicing MVC style programming. I have a Mastermind game in a single file, working fine (maybe apart of the fact that "Check" button is invisible at start). But when I've rewritten it to model, view,…
  • 1,357
  • 2
  • 9
  • 3
7 answers

Unable to set data attribute using jQuery Data() API

I've got the following field on an MVC view: @Html.TextBoxFor(model => model.Course.Title, new { data_helptext = "Old Text" }) In a seperate js file, I want to set the data-helptext attribute to a string value. Here's my…
Jason Evans
  • 28,906
  • 14
  • 90
  • 154
10 answers

Is MVC a Design Pattern or Architectural pattern

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…
  • 5,423
  • 2
  • 28
  • 42
4 answers

Django vs. Model View Controller

Can somebody explain me where the diferences are between Django and the Model View Controller pattern? Functionally, what can we expect from those differences — i.e. what works differently comparing Django to, for example, Ruby on Rails?
  • 2,484
  • 2
  • 25
  • 37