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 [asp.net-mvc] or [asp.net-core-mvc] 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:

MVC

Reference

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
49
votes
3 answers

Looking for clean WinForms MVC tutorial for C#

How to create a rich user interface Windows application, example Photo Shop. I am looking for clean MVC tutorial for WinForms with C# somewhere. (Not ASP.NET MVC.) Being new on the Windows Platform; most MSDN and internet tutorials basically puts…
s5804
  • 995
  • 3
  • 12
  • 14
49
votes
7 answers

MVC: Data Models and View Models

I've read some MVC advice in the past regarding models stating that you should not reuse the same model objects for the domain and the view; but I haven't been able to find anyone willing to discuss why this is bad. It is my opinion that creating…
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
49
votes
6 answers

How to change the default path of view files in a Rails 3 controller?

I have a controller called ProjectsController. Its actions, by default, look for views inside app/views/projects. I'd like to change that path for all methods (index, show, new, edit etc...) in the controller. For example: class ProjectsController <…
Yuval Karmi
  • 26,277
  • 39
  • 124
  • 175
49
votes
5 answers

In a MVC application, should the controller or the model handle data access?

We are having some philosopical debates in our company about where the calls to the Business Logic should be to perform CRUD operations. I believe that the Model should consist of your data structure and that the controller should be responsible for…
Scottie
  • 11,050
  • 19
  • 68
  • 109
48
votes
5 answers

How to catch exception in flutter?

This is my exception class. Exception class has been implemented by the abstract exception class of flutter. Am I missing something? class FetchDataException implements Exception { final _message; FetchDataException([this._message]); String…
P-RAD
  • 1,293
  • 2
  • 15
  • 36
48
votes
24 answers

Can't find ADO.net Entity Data Model template in VS2017

I was trying to create an ASP.NET MVC web application in Visual Studio 2017. I need to take an EF database-first approach for the work. Unfortunately I can't find the ADO.NET Entity Data Model template in my "Data" template folder: I have tried…
48
votes
3 answers

Service Layers and Repositories

I've been using MVC frameworks for a short while now and I really like how the concerns are separated out. I've got into a bad habit of letting the controllers do quite a bit of work. So I'm really looking for some advice. When I first started…
47
votes
11 answers

What is MVC and what are the advantages of it?

I found What are mvp and mvc and what is the difference but it didn't really answer this question. I've recently started using MVC because it's part of the framework that myself and my work-partner are going to use. We chose it because it looked…
Teifion
  • 108,121
  • 75
  • 161
  • 195
46
votes
5 answers

SproutCore vs. Cappuccino

Aside from the language differences Javascript vs. Objective-J what benefits does Cappuccino provide over SproutCore and vice-versa in your experiences? In terms of a long-term forecast, is SproutCore more "supported" than Cappuccino because it is…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
46
votes
6 answers

Should a user control have its own view model?

I have a window made up of several user controls and was wondering whether each user control have its own view model or should the window as a whole have only one view model?
AwkwardCoder
  • 24,893
  • 27
  • 82
  • 152
45
votes
2 answers

Backbone.js - where to store state information?

I'm new to Backbone.js, and I'm trying to figure out where state variables should live. My use case: I have an application that provides a reading interface for a book (I know, classic example, right?). My models are Book and Page with collection…
nrabinowitz
  • 55,314
  • 10
  • 149
  • 165
45
votes
6 answers

Where can I find clear examples of MVC?

I've read a couple of things about MVCs but I still don't understand when they should be used and when they shouldn't be used. I am looking for clear examples that say things like "if you're developing this then you should use MVC, like this" and…
Tom
  • 6,991
  • 13
  • 60
  • 78
45
votes
12 answers

How to show a PDF file in a Django view?

Is it possible to show a PDF file in the Django view, rather than making the user have to download it to see it? And if it is possible, how would it be done? This is what I have so far - @login_required def resume(request, applicant_id): #Get…
SImon
  • 839
  • 2
  • 10
  • 13
44
votes
2 answers

MVC / MVP / MVVM What the Heck?

I recently worked on a .Net WPF project to build a retail point of sale system where I used the MVP pattern for the first time. It took me a little while to wrap my head around the change of approach but once I did that I thought that the concept…
Steve
  • 2,073
  • 4
  • 27
  • 39
43
votes
3 answers

MVC implemented in pure C

Does anybody know of any resources that provide a straight forward example of trying to do Model View Controller design pattern in a C context? And in particular an embedded system? To clarify, I am not interested in C#, C++, Objective-C, Java, PHP…
Gordon Potter
  • 5,802
  • 9
  • 42
  • 60