3 ms·
> You take a table from the database and put it into an html tag table. > Do you want your view to know how to connect to a db? I think this is where there's
by throw310822 3y ago
> You take a table from the database and put it into an html tag table.
> Do you want your view to know how to connect to a db?
I think this is where there's a misunderstanding: you think of your model as "a database". A database is not a model, a database is just a storage layer. A model is an object that provides an api with high-level business operations and views on data.
At that point, your view needs only to receive from the model the pre-digested data it provides and translate it into html. Similarly, the controller only needs to translate user input in terms of high-level operations on the model, without ever having to interface with a database.
- bonzini 3y agoIn fact the original MVC was done with Smalltalk which has a persistent image. So the Smalltalk system itself _is_ the storage layer in which model objects live.
- cies 3y agoThis! Also the original MVC (not the req-resp cycle Model2) was not for client-server split apps. It was for desktop apps, so the Model could update the view. Now with WebSockets we're coming full circle.
- 0tt049 3y agoExactly! No rows, tables or SQL. But instances of Models in a persistent image.
- DougBTX 3y ago> A model is a ... view on data. I think this is part of the reason the MVC names persist, they are so generic that you can describe the Model as a type of View!
- layer8 3y agoMVC “view” is on the user level, the model is a “view” (facade/adapter/whatever) on the programmatic level.