Questions tagged [mvc]

MVC (Model-View-Controller) is a software architecture pattern that enforces separation of concerns.

MVC (Model-View-Controller) is a software architecture pattern that enforces separation of concerns. By isolating these components development, testing and maintenance can occur independently, reducing dependencies in the code.

Model

The model concerns itself with how the data is stored, retrieved and the business concepts that derive from the data should be interpreted.

View

The view concerns itself with how the data is presented, formatted and interacted with.

Controller

The controller concerns itself with the rules for how the view may change the model, what information can be accessed and what changes are allowed to be made.

951 questions
34
votes
1 answer

Is a good practice to call a Controller function from another Controller?

I'm having a case where I'm handling the logic of a search in one controller and I'm generating some data based on searches and returning as statistics. Is a good practice calling a controller function from another controller? Or two controllers…
IAmJulianAcosta
  • 537
  • 1
  • 5
  • 11
31
votes
9 answers

Explain MVC to non-programmers

I have a need to explain MVC to non-programmers. Namely, to managers of other departments, in the context of progress report. One of the things I do is refactor our codebase towards MVC separation. What is MVC separation they might ask? Why is it…
Dennis
  • 8,217
22
votes
5 answers

In an MVC system, where should the database persistence code sit?

I've seen multiple configurations for persisting information to the database. Generally, three types of designs seem common in my corner of the world: Controller manages the persistence Model manages the persistence Third party library manages the…
18
votes
4 answers

One controller per page or many pages in one controller?

I just wanted some advice regarding the MVC way of doing things. I am using codeigniter and I was wondering if it's better to have one controller per page for a website or to have one controller for all the pages? Let's say I have a simple website…
Rushino
  • 539
  • 1
  • 6
  • 13
16
votes
7 answers

Is the MVC pattern used in industry a lot? What's all the hype?

I'm a student but I am hopefully moving into the software industry soon. There seems to be a lot of hype about the MVC software pattern. I noticed that PHP frameworks are often MVC, what about non-web languages.. is it the same with them? For my…
ale
  • 1,046
16
votes
7 answers

In an MVC architecture, how closely coupled are the Model and View to the Controller?

I've got an app which uses MVC, but I'm struggling a little as to how the controller should be architected. For example, the View is only viewing some subset of the model's data at once. However, I'm unsure as to exactly how this should be arranged.…
DeadMG
  • 36,902
14
votes
5 answers

Is Unit Testing the primary objective of MVC Pattern?

Recently in an interview, one of the questions was 'Why do we use MVC?’ I just answered that it is much closer to how, many of the real world systems are! Explained the benefits it has when it comes to Maintainability, Scalability etc. But they were…
WinW
  • 1,003
  • 1
  • 8
  • 19
14
votes
5 answers

Should Controller know about View & Model? or vice versa?

I'm conceptually trying to understand if I should be doing this: item = Model() screen = View() brain = Controller(item, screen) or this.. brain = Controller() item = Model(brain) screen = View(brain) or this.. class Controller(): def…
alnafie
  • 281
12
votes
3 answers

Global constant values throughout MVC site

My MVC (.NET) has some constant values through out the site, such as the phone number, physical address, email address etc. I'd like to store this value once, so future updates are easier for when they change their details. To make my question…
Dave
  • 662
11
votes
6 answers

How to determine what should get its own respective controller?

I'm using the MVC pattern in my web application built with PHP. I'm always struggling to determine whether I need a new dedicated controller for a set of actions or if I should place them inside an already existing controller. Are there any good…
10
votes
3 answers

MVC : Fully populated models or Partially Filled Models?

This one has haunted me for so long. When doing MVC programming what do you think is the better programming practice? Should one use fully populated models or the partially filled ones, especially when I know that for this particular task I am going…
7
votes
2 answers

mvc pattern - splitting model into data-access and business logic layers

I've had a chance to try it out and I like it very much. I'm thinking of using it in all of my future projects. I'd like to hear some critique and opinions about it. I've done a little research on the subject and I'm not sure I've seen this approach…
Ajant
  • 71
7
votes
3 answers

Shouldn't MVC be MCV?

The model is defined first, then the controllers are fired based on the user request, and they will generate the views (the output). So it should be M->C->V, right?
Ella
  • 187
6
votes
3 answers

Would this constitute MVC - even in a very loose sense?

I've been working on a kind of CRM for the sales guys in our office - not as a job role but as a spare time task type of thing - I don't claim to be a developer or anything like that, but I would definitely like to pursue a career as a web developer…
5
votes
5 answers

MVC shared model different required fields on different type

I have a model called Car and depending on what type of Car the user select the view is presented differently. For example the user selects from a grid of different cars and depending if it is a Volvo or a Kia or a Ford the view must allow different…
kurasa
  • 151
1
2 3 4