▲ | aryehof 4 days ago | |||||||
This perpetuates the myth that a model is an object. One object. This has lead to todays common misconception that a model is one anaemic data-bucket representing typically a database table. Instead a model is one or more collaborating objects. | ||||||||
▲ | hansvm 4 days ago | parent | next [-] | |||||||
And what do you call the Model object holding those collaborating objects? Is that not still one object? The article explicitly supports your position that models can be complicated (see the paragraph starting with "to support more complex views"). | ||||||||
▲ | globular-toast 4 days ago | parent | prev | next [-] | |||||||
"Model" is an overloaded term. In Domain-Driven Design there is the domain model at the centre of the application. One model consisting of many classes (entities and value objects), functions etc. Then there's the ORM thing, particularly active record ORMs, where "a model" means a database table. And things like serialisation libraries (e.g. Pydantic) where "a model" is one type. Something that changed how I thought of it was in Robert Martin's Clean Code where the says the whole MVC lives in the outer layers of the application. So basically, "model" is context specific. It depends what part of your application you're talking about. MVC is about building GUIs, that's it. An application usually consists of a lot more. | ||||||||
| ||||||||
▲ | mpweiher 4 days ago | parent | prev [-] | |||||||
I actually find it useful to have the Model represented by a single object, usually a facade that coordinates all the other Model objects. Not sure why this would lead to anemic models, which I completely agree are a common anti-pattern. In fact, to me it seems rather the opposite would be true: having the single object facade facilitates having a complex model that coordinates all the different pieces to represent a unified view of said model to the views, which can then be very simple and transparent. In turn, when the models were coupled with views individually, that has tended to lead to exactly that View → DB Table mapping of dumb data objects you rightly criticize. |