C
C#2y ago
Baaleks

❔ MVC

In MVC the model updates the view. Does that mean the code for that actual update resides within the model or in the view?
7 Replies
cap5lut
cap5lut2y ago
business logic resides within the model space, imagine u would have 2 different views for the same model, then u would have to implement the business logic twice
Baaleks
BaaleksOP2y ago
yeah i know. But at some point you would want to get data from the model to update the view right? In your exmample potentially having more than one view that would mean that the code to get that update would be in the view space right? So that you would't have to alter the model code
cap5lut
cap5lut2y ago
well, u pass the model to the view, the view "builds itself" based on the model's data basically all the interface logic resides in the controller, the controller then calls the respective update logic on the model and triggers the update in the view afterwards basically in the scope of web thats: http request -> model update business logic -> render new view based on the model -> http response basically the controller's job is to wire the stuff together the model doesnt even know the view exists, the view doesnt know the controller exist and the controller knows both ;p
Baaleks
BaaleksOP2y ago
aha that makes sense so i should put all my code for updating my View based of data recevied from a server in my view none of it goes in the model
cap5lut
cap5lut2y ago
yes
JakenVeina
JakenVeina2y ago
in MVC, logic resides in the controller the model does not update the view, the controller does by watching for/listening to model changes
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server