I am seriously confused about the concept of Models in MVC. Most of the currently existing frameworks place the model between the controller and the database, and the model almost acts as a database abstraction layer. The concept of "Fat Model Skinny Controller" is lost as the controller starts more and more logic.
In DDD, there is also the concept of Domain Entity, which has a unique identifier for it. As far as I understand, a user is a good example of Entity (for example, a unique user identifier). An entity has a life cycle — values ​​can change throughout an action, and then are stored or discarded.
The entity described above is what I thought the model should be in MVC? How am I outside the base?
To clutter things up more, you drop other templates, such as a repository template (perhaps by placing a Service there). It's pretty clear how the Repository will interact with Entity - how does this happen with the model?
Controllers can have several models, which makes it look like a model that is smaller than a “database table” than a unique entity.
UPDATE: In this post, the Model is described as something with knowledge, and it can be singular or collection of objects. So this is more like an entity and a model, more or less the same. A model is an all-encompassing term where an entity is more specific. The Value object will also be a model. At least from the point of view of MVC. May be???
So, in very rude terms, which is better?
No "model" really ...
class MyController { public function index() { $repo = new PostRepository(); $posts = $repo->findAllByDateRange('within 30 days'); foreach($posts as $post) { echo $post->Author; } } }
Or is it that has a model like DAO?
class MyController { public function index() { $model = new PostModel();
Both of these examples did not even do what I described above. I am clearly lost. Any input?
php model-view-controller entity domain-driven-design model
Nathan Loding Jun 12 '10 at 20:12 2010-06-12 20:12
source share