All Questions
Tagged with model model-view-controller
939
questions
578
votes
5
answers
202k
views
How should a model be structured in MVC? [closed]
I am just getting a grasp on the MVC framework and I often wonder how much code should go in the model. I tend to have a data access class that has methods like this:
public function CheckUsername($...
115
votes
7
answers
72k
views
What is the difference between an MVC Model object, a domain object and a DTO
What is the difference between a MVC Model object, a domain object, and a DTO?
My understanding is:
MVC Model object:
Models the data to be displayed by a corresponding view. It may not map directly ...
85
votes
4
answers
73k
views
Differentiating between domain, model, and entity with respect to MVC
Can someone explain these 3 concepts and the differences between them with respect to an MVC framework along with an example. To me these appear almost equivalent, and it seems they are used ...
76
votes
2
answers
13k
views
Fat models, skinny controllers and the MVC design pattern [closed]
I just read a blog post that explains MVC with a banking analogy. I have a few months of experience with web application development with an MVC framework (CakePHP), so I get the basics, but I began ...
70
votes
5
answers
33k
views
DDD and MVC: Difference between 'Model' and 'Entity'
I'm seriously confused about the concept of the 'Model' in MVC. Most frameworks that exist today put the Model between the Controller and the database, and the Model almost acts like a database ...
49
votes
7
answers
12k
views
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 ...
42
votes
4
answers
169k
views
How to set a hidden value in Razor
I know that what I'm trying to do is bad idea, but I have specific constrains for now.
I have multiple sites, using one and the same MVC3 code base. For one of them the requirement is to hide some ...
34
votes
11
answers
43k
views
Models in the Zend Framework
What are some of the ways you have implemented models in the Zend Framework?
I have seen the basic class User extends Zend_Db_Table_Abstract and then putting calls to that in your controllers:
$foo ...
34
votes
5
answers
41k
views
MVC :: What is a model?
I am at a point where I must make a decision about models. I am aware that models are what you use to do all your database manipulation. But are models restricted to this?
Are they meant only for ...
30
votes
1
answer
32k
views
ES6 Classes for Data Models
I'm trying to use ES6 Classes to construct data models (from a MySQL database) in an API that I'm building. I prefer not using an ORM/ODM library, as this will be a very basic, simple API. But, I'm ...
27
votes
4
answers
18k
views
Backbone change model of View
I am fairly new to Backbone and have the following question:
I have a collection of models.
I have a collection view displaying tabs (with a view for each model in the collection).
I have a view ...
26
votes
4
answers
24k
views
How to validate only part of the model in ASP .NET MVC?
I have a large model (large I mean model class contains a lot of fields/properties and each has at least one validation attribute (such as Required, MaxLength, MinLength etc)). Instead of creating one ...
26
votes
1
answer
10k
views
Django MVC pattern for non database driven models?
I'm just working my way through Django, and really liking it so far, but I have an issue and I'm not sure what the typical way to solve it.
Suppose I have a View which is supposed to be updated when ...
24
votes
7
answers
9k
views
Where does input validation belong in an MVC application?
I have a MVC application that receives an input from a form.
This is a login form so the only validation that is necessary is to check whether the input is non-empty.
Right now before I pass it to the ...
23
votes
1
answer
11k
views
JavaBean wrapping with JavaFX Properties
I want to use JavaFX properties for UI binding, but I don't want them in my model classes (see Using javafx.beans properties in model classes). My model classes have getters and setters, and I want to ...
21
votes
4
answers
9k
views
ForeignKey to abstract class (generic relations)
I'm building a personal project with Django, to train myself (because I love Django, but I miss skills). I have the basic requirements, I know Python, I carefully read the Django book twice if not ...
18
votes
6
answers
14k
views
Is Backbone.js really an MVC? [closed]
backbone.js has been spoken of as an MVC framework for Javascript. But is it?
Here is the description of the model, from http://documentcloud.github.com/backbone/
Models are the heart of any ...
17
votes
2
answers
31k
views
Creating Qt models for tree views
I'm writing an application in Qt (with C++) and I need to represent an object structure in a tree view. One of the ways to do this is to create a model for this, but I'm still quite confused after ...
17
votes
3
answers
11k
views
How to deal with model classes in iOS application
I am a newbie in iOS application development, but I am trying to learn how to deal with Cocoa in the best way.
I got stuck trying to understand how to keep and reference the model objects properly.
...
16
votes
1
answer
4k
views
What are the differences between Joomla Model Types?
I'm trying to get to grips with the power behind Joomla (3.x)'s framework.
I've noticed that there are multiple types of model that can be used in a component:
JModelAdmin
Prototype admin model. Acts ...
14
votes
4
answers
15k
views
MVC - which methods should be in Model class except set/get members?
Should methods that manipulate the Model class members be implemented in the Model or in the Controller? Does it depend on how "heavy" this manipulation is ?
By "manipulation" I mean:
get a class ...
13
votes
7
answers
2k
views
What exactly is the model in MVC
I'm slightly confused about what exactly the Model is limited to. I understand that it works with data from a database and such. Can it be used for anything else though? Take for example an ...
13
votes
2
answers
8k
views
How to delete one-to-one relating models cascading in django?
Background:
I have the below models defined in Django(1.8.5):
class PublishInfo(models.Model):
pass
class Book(models.Model):
info = models.OneToOneField(
PublishInfo, on_delete=...
12
votes
5
answers
7k
views
Difference between Controller and Model in MVC
I'm little confused about controller and model in MVC framework (codeIgniter). Its clear to me that controller methods calls the views and Model methods interact with database.
However, I'm little ...
12
votes
3
answers
9k
views
In MVC, does an ORM represent the model?
In MVC, is the ORM the same as the model or just a way the model can be designed? In other words, the "model" doesn't care how you get data as long as you get it. Or, does "model" imply that I no ...
11
votes
3
answers
16k
views
MVC 2 - Data Annotation for Label?
Is there an annotation to set the Label-name of the property?
Ex:
public class MyModel
{
[LabelName("Your Phone")]
public string Phone{get;set;}
}
Thanks
And then in the view, it would show the ...
11
votes
4
answers
16k
views
Properly calling the database from Model in an MVC application?
I'm building a tiny MVC framework for learning/experimenting and small project purposes. I needed to find out the basics of the internals of the Model since a full MVC framework and ORM is overkill ...
11
votes
3
answers
8k
views
Models in Symfony2, and other MVC frameworks?
I'm trying to understand how Models work in proper MVC.
As far as I know, Models in MVC is where the application logic happens, Models are meat, or back bone of MVC. Views are just presentation, and ...
11
votes
4
answers
6k
views
How to create a triple-join table with Django
Using Django's built in models, how would one create a triple-join between three models.
For example:
Users, Roles, and Events are the models.
Users have many Roles, and Roles many Users. (...
11
votes
3
answers
8k
views
Can a controller catch an exception thrown from a model?
Well, it is technically possible, but would this break the MVC architecture?
I'm not sure whether this type of communication is recommended between both controller and model. I will describe it using ...
11
votes
2
answers
741
views
How would the 'Model' in a Rails-type webapp be implemented in a functional programming language?
In MVC web development frameworks such as Ruby on Rails, Django, and CakePHP, HTTP requests are routed to controllers, which fetch objects which are usually persisted to a backend database store. ...
10
votes
7
answers
38k
views
Disable Model Validation in Asp.Net MVC
How do I disable Model validation for a single Action in a Controller ?
Or can I do it per model by registering the model type at startup somewhere ?
I want the ModelBinder to bind to the model, but ...
10
votes
6
answers
4k
views
MVC: Where should I format data?
I get data from Model (an array with data) and I need to display with a specific format. I need to iterate over the array, format the data and then display it. Where should I format data to display? ...
10
votes
1
answer
5k
views
Communication between the View and Model in MVC
After reading from many different sources, I am very confused about how View and Model should communicate in the MVC pattern. To my understanding, the accepted answer of this post and this article ...
9
votes
2
answers
12k
views
Backbone.js + Spring MVC. Save model
When I send a request from JSP FORM, the server side automatically parses data to my ModelObject. But when I send requests from Backbone save() my ModelObject is empty on Server Side. How can I do it ...
9
votes
2
answers
6k
views
Why do we no longer need to manually validate models in higher versions of ASP.NET Core?
All my models are automatically validated before hitting the endpoint, and return appropriate errors if some form of validation has failed.
I remember back in ASP.NET Core 2.2 we needed to manually ...
9
votes
2
answers
28k
views
How do you pass data from a controller to a model with Ruby on Rails?
How do you pass data from a controller to a model?
In my application_controller I grab the user's location (state and city) and include a before_filter to make it accesible in all my controllers via
...
9
votes
3
answers
3k
views
Can a utility class be a Model class in a MVC framework?
Im designing a MVC framework but I dont know where should I put my utility classes. I read somewhere where it said utility classes are Model Classes. Is this line of thinking correct or are they some ...
9
votes
2
answers
3k
views
Zend Framework ORM-style table data gateway vs. extending Zend_Db_Table_Abstract
In the Zend Framework Quickstart, there has been a change from models that extend Zend_Db_Table_Abstract to the Table Data Gateway pattern.
Personally, I have not had much experience with this ...
9
votes
1
answer
847
views
MVC Mayhem; Sorting out Model responsibility and structure
My understanding of MVC-type architectures over the last few weeks/months has advanced (I'd say) considerably, and I owe most of my thanks to fellow SO enthusiasts; so, thank you!
I'm still ...
9
votes
1
answer
4k
views
Should enums be considered as models?
I'm in a state of a design dilemma wherein I'm unable to decide whether an enum should be considered as a part of models or not. The definition I have for models is that they represent knowledge.
With ...
8
votes
3
answers
3k
views
Why is auth typically in the Controller in MVC?
I've been doing a lot of tutorials for different MVC frameworks, and it seems very typical for Authorization to take place in the Controller. Why?
My thought is the Controller should only be used to ...
8
votes
4
answers
15k
views
Object oriented approach with AngularJS
It seems that Angular does not provide a built-in solution to define class instances with properties and methods and that it's up the developer to build this.
What is the best practice to do this in ...
8
votes
1
answer
2k
views
Django: find all reverse references by foreign keys
Well, now I'm using Django 1.6+
And I have a model:
class FileReference(models.Model):
# some data fields
# ...
pass
class Person(models.Model):
avatar = models.ForeignKey(...
7
votes
2
answers
9k
views
What's the role of the Model in MVC?
I've read a few articles about MVC but there's one thing that isn't clear to me. What is the role of the model in practical term.
Does the model represent the business object?
Or is it just a class ...
7
votes
1
answer
7k
views
MVC - do I need to use Controller in the View?
As I know in the standard implementation of the MVC we pass Controller and Model to the View
But Im a little bit disagree with this idea. I dont want my view to know about both controller and model (...
7
votes
3
answers
3k
views
Error Handling in Model (MVC)
I was wondering what the excepted standard is for handling errors in the Model.
Currently I have 'setError' and 'getError' methods that's in use by all my Models.
This means I'm only concerned with ...
7
votes
6
answers
356
views
MVC: I need to understand the Model
I've been working with the MVC pattern for a while now, but I honestly don't feel like I truly understand how to work with and apply the "Model" ... I mean, one could easily get away with using only ...
6
votes
2
answers
15k
views
Design Pattern - Objective-C - MVC Model View Controller
Hi I already read tutorials around the web on MVC and already read the topics on here. I think i got the concept of the MVC but i'm not sure of its implementation.
I've tried to apply it to a simple ...