Questions tagged [mvc]
MVC (Model-View-Controller) is a software architecture pattern that enforces separation of concerns.
83
questions
6
votes
1
answer
717
views
MVC: Display requested content via the View
I'm trying to learn how the MVC pattern works so have been playing around a bit. I just wrote this, which was making sense to me, until I wanted to display the array content which has been collect by ...
218
votes
10
answers
232k
views
What is MVC, really?
As a serious programmer, how do you answer the question What is MVC?
In my mind, MVC is sort of a nebulous topic — and because of that, if your audience is a learner, then you're free to ...
52
votes
3
answers
67k
views
Where to put business logic in MVC design?
I have created a simple MVC Java application that adds records through data forms to a database.
My app collects data, it also validates it and stores it. This is because the data is being sourced ...
67
votes
13
answers
8k
views
Why is it a good idea for "lower" application layers not to be aware of "higher" ones?
In a typical (well-designed) MVC web app, the database is not aware of the model code, the model code is not aware of the controller code, and the controller code is not aware of the view code. (I ...
11
votes
2
answers
24k
views
.NET MVC project architecture / layering
When planning the architecture for a mid-large scale MVC web application how do you implement the layers to be as decoupled as possible and easy to test? (basically follow best practices) Let's say I'...
74
votes
5
answers
104k
views
Why put the business logic in the model? What happens when I have multiple types of storage?
I always thought that the business logic has to be in the controller and that the controller, since it is the 'middle' part, stays static and that the model/view have to be capsuled via interfaces. ...
19
votes
2
answers
46k
views
What is the best way to create REST API error response model and error codes system?
My REST implementation will return errors in JSON with next structure:
{
"http_response":400,
"dev_message":"There is a problem",
"message_for_user":"Bad request",
"some_internal_error_code":...
77
votes
7
answers
102k
views
Why should I use an MVC pattern?
It seems everyone doing web applications nowadays wants to use MVC for everything. I find it hard to convince myself to use this pattern, however. I understand the general idea is to separate the ...
27
votes
6
answers
13k
views
Testing: deterministic or non-deterministic?
Is it better to have either a
Deterministic test suite, that results in the same tests succeeding
Non-deterministic test suite, which potentially possibly covers more cases
?
Example:
You write a ...
40
votes
2
answers
39k
views
Mixing Angular and ASP.NET MVC/Web api?
I come from using ASP.NET MVC/Web API and now I am starting to use Angular but I am not clear on the proper way to mix them.
Once I am using Angular does the MVC server side concepts still provide ...
33
votes
4
answers
21k
views
In MVC should a model handle validation?
I am trying to re-architect a web application I developed to use the MVC pattern, but I'm not sure if validation should be handled in the model or not. For example, I'm setting up one of my models ...
47
votes
6
answers
28k
views
How much business logic should be allowed to exist in the controller layer?
Sometimes we have some business logic represented in the controller code of our applications. This is usually logic that differentiates what methods to call from the model and/or what arguments to ...
5
votes
4
answers
4k
views
To MVC or not MVC, that is the question
Originally, I started off doing jQuery plugins, then moved onto Backbone.js applications, then been experimenting with MicroJS MVC modules, but these days I'm even wondering if there is any need for ...
4
votes
1
answer
2k
views
Do I need JUnit tests for the controller layer on a MVC when I have a database layer
I have a MVC which has this structure:
ui
controller
db
model
Basically the controller doesn't really do much more than connection ui with db layer.
Do I need to provide JUnit tests for the ...
65
votes
14
answers
36k
views
Isn't MVC anti OOP?
The main idea behind OOP is to unify data and behavior in a single entity - the object. In procedural programming there is data and separately algorithms modifying the data.
In the Model-View-...
31
votes
3
answers
8k
views
Is it reasonable to build applications (not games) using a component-entity-system architecture?
I know that when building applications (native or web) such as those in the Apple AppStore or Google Play app store that it's very common to use a Model-View-Controller architecture.
However, is it ...
17
votes
3
answers
21k
views
Model-View-Controller: Does the user interact with the View or with the Controller?
I have recently learned about the MVC design pattern. I'm learning from the Head First Design Pattern book.
According to this book (if I understand correctly):
The Model is most of the application ...
15
votes
4
answers
31k
views
Use a service layer with MVC
If a controller gets too fat and model instantiation starts to add up, a service layer could be used.
If I just wrap the logic inside a service class, I will get a bunch of Services with one/two ...
21
votes
5
answers
19k
views
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 ...
20
votes
5
answers
9k
views
MVC: Does the Controller break the Single Responsibility Principle?
The Single Responsibility Principle states that "a class should have one reason the change".
In the MVC pattern, the Controller's job is to mediate between the View and the Model. It offers an ...
13
votes
4
answers
6k
views
Explain Model View Controller
My experience with developing dynamic websites is limited mostly to Java servlets. I've used Tomcat to develop various Java servlets, and I wouldn't hesitate to say that I'm reasonably proficient ...
10
votes
5
answers
6k
views
In MVC, can/should basic data retrieval from the Model be done in the View?
Given the concept of 'skinny controllers, fat models' and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and ...
6
votes
2
answers
2k
views
How does MVC work with the principle "Tell, Don't ask"?
Procedural code gets information then makes decisions. Object-oriented
code tells objects to do things.
— Alec Sharp
So, when a view wants to display some information that is suppose to be derived ...
5
votes
4
answers
2k
views
Where to put User Interface/Domain Model manipulation logic (transferring data from the view to Domain Model)
We are starting on a greenfield project in ASP.NET MVC. I've used the MVC pattern in other stacks (PHP and Ruby) and I keep running into the same problems of where to place business logic, UI logic, ...
5
votes
1
answer
2k
views
Should website frontends be rendered in client-side or server-side?
I've been talking to a colleague that comes from AS3 to the HTML world. He has created a small website (there are apparently no dynamic contents) following the no-flash rules for his very first time, ...
11
votes
4
answers
7k
views
Why would you use MVC over Web Forms?
Recently an architect described our company as offering a Rolls-Royce solution (MVC) when all he needed was a Toyota (Web Forms).
I'm curious to find out what you think about web forms vs MVC as an ...
2
votes
4
answers
5k
views
Building websites, which is the better approach MVP or MVC?
I'm looking for feedback on MVP and MVC patterns used as a framework to build a website. I've used both with a certain degrees of success and failure. Furthermore I've worked in places which have ...
1
vote
3
answers
5k
views
What are the steps to grouping related classes into packages
What are the steps needed to be taken to group related classes into packages in Java?
In my case, I have about a number of .java files that I'd like to group into 3 packages according to the MVC ...
339
votes
14
answers
91k
views
Should you write your back-end as an API?
I had a heated discussion today about our MVC application. We have a website written in MVC (ASP.NET), and it usually follows the pattern of do something in the view -> hit the controller -> ...
37
votes
2
answers
45k
views
MVCS - Model View Controller Store
I recently decided to start learning iOS Development, and to this end I’ve been reading iOS Programming: The Big Nerd Ranch Guide. In the book the authors describe a design pattern MVCS - Model-View-...
50
votes
11
answers
28k
views
Best practice or design patterns for retrieval of data for reporting and dashboards in a domain-rich application
First, I want to say this seems to be a neglected question/area, so if this question needs improvement, help me make this a great question that can benefit others! I'm looking for advice and help from ...
33
votes
1
answer
92k
views
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 ...
26
votes
6
answers
20k
views
Where should I put an API request in MVC?
I'm building a web application using a MVC pattern. Following this kind of architecture we can see that all the methods used to interact with database are implemented in the model.
But what happen if ...
16
votes
3
answers
4k
views
Massive View Controller - IOS - Solutions
I'm sure every new iOS developer has the following problem: The View Controllers get very fast crowded with code for various purposes, easily getting to 500 + lines of code.
This is how it looks like ...
48
votes
7
answers
20k
views
Why does everyone put controllers in one folder and views in another?
I'm getting ready to take the bend out of asp and into an mvc framework, asp.net mvc or nancy. Wherever I go, I see folders for controllers/modules and folders for views. Is this just a pavlovian ...
31
votes
7
answers
3k
views
Is it possible for business logic not to creep into the view?
I've developed for several web application projects for the last 3 years, both personal and at work, and I can't seem to figure out whether it's possible for at least some business logic not ending up ...
10
votes
3
answers
17k
views
Best Architecture for ASP.NET WebForms Application
I have written an ASP.NET WebForms portal for a client. The project has kind of evolved rather than being properly planned and structured from the beginning. Consequently, all the code is mashed ...
20
votes
2
answers
28k
views
How do you separate view from logic in a Winform application?
I know there are patterns like MVC to separate view from logic, however, I don't know how common they are in Winform applications.
For a C# Winform application, I may start with a Form and gradually ...
16
votes
7
answers
16k
views
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 ...
7
votes
1
answer
6k
views
Where we should not use MVC? [duplicate]
I have a software engineering course project that we should design a web application, so I've decided to read about software architecture patterns.
I've read a lot about what is MVC and its structure,...
13
votes
3
answers
21k
views
MVVM or MVC? Want to use the same set of classes for WPF and ASP.NET
I am a newbie in terms of Design Patterns. I just started learning MVC when I am hearing a new buzz, MVVM.
I want to learn the insights of both of these by redesigning an old inventory and invoicing ...
8
votes
5
answers
4k
views
Most MVC-strict php framework [closed]
I have been trying to wrap my head around MVC pattern for about 6 months.I've read tons of articles, Q&A, and blog posts about MVC and HMVC patterns, but I just simply don't get it 100%.
I tried ...
22
votes
6
answers
22k
views
In MVC, what is the difference between controller and router?
Do they mean the same thing (attaching URLs to actions, or actions to URLs) or is there any difference I'm missing?
Example: http://github.com/dannyvankooten/PHP-Router vs. http://konstrukt.dk
10
votes
2
answers
13k
views
Use-cases for node.js and c#
I do quite a bit of ASP.NET work (C#, MVC), but most of it is typical web development. I do Restful architecture using CRUD repositories. Most of my clients don't have a lot of advanced requirements ...
14
votes
13
answers
6k
views
Where is the M in MVC?
I'm trying to refactor my application into MVC, but I'm stuck on the M part.
In a database-backed app, the model is implemented in the app code, right?
But then, what is in the database -- is that ...
4
votes
5
answers
577
views
Is SOA suitable for developers or only for business/IT management people?
Let's suppose you're the lead of a team of developers that needs to build a big information system such as an ERP or Human Resources software, or whatever system that is composed by multiple business ...
3
votes
1
answer
383
views
Models Views and Controllers jobs
First, I know there are lot of answers about MVC but I need some more-specific ansewer based on my probably wrong understanding of MVC.
I've already read this very good answer (Explain Model View ...
14
votes
5
answers
12k
views
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(...
6
votes
5
answers
3k
views
JQuery / JSON + .Net Service Layer - to WCF or Not to WCF?
I Recently had a discussion with a colleague of mine about the pros / cons of WCF. He mentioned about how much code is generated to support WCF, and also the overhead required. It was mentioned that a ...
5
votes
4
answers
18k
views
What is the actual purpose of MVC?
I've seen a lot of stuff that describes how it's done, but not a lot that tells WHY it's done. Is it just a way to keep the code readable, or is there a better reason?