Skip to main content
edited body
Source Link
Kazimierz Jawor
  • 19.1k
  • 7
  • 38
  • 58

If a view needs to acces data from a model, do you think the controller should:

a) pass the model to the view
b) pass the data of the model to the view
c) neither; it shouldn't be the controllers concern. Let the view access the model directly to retrieve the data. Only let the controller give some parameters the view needs to filter the data from the model.
d) it depends on the situation.
e) none of the above, but [...]

Thanks

After some debate in the comments to an answer that was deleted by the user, maybe this needs clarification. My view of the MCVMVC architecture is biased towards that of the Zend Framework (php) in which an action in a controller by default has a default view assigned to it. So it's not so much the model that dictates which view is approporiate, but rather the controller. Do you feel the model should dictate what view is appropriate? The only way I see fit to let the view be build based on a model, is by letting the controller pass the model to the view. Are there other techniques to let a view access a model without the controller being involved? Or is it perfectly fine to let a controller pass the model to a view, so that the view can be build based on the models attributes?

If a view needs to acces data from a model, do you think the controller should:

a) pass the model to the view
b) pass the data of the model to the view
c) neither; it shouldn't be the controllers concern. Let the view access the model directly to retrieve the data. Only let the controller give some parameters the view needs to filter the data from the model.
d) it depends on the situation.
e) none of the above, but [...]

Thanks

After some debate in the comments to an answer that was deleted by the user, maybe this needs clarification. My view of the MCV architecture is biased towards that of the Zend Framework (php) in which an action in a controller by default has a default view assigned to it. So it's not so much the model that dictates which view is approporiate, but rather the controller. Do you feel the model should dictate what view is appropriate? The only way I see fit to let the view be build based on a model, is by letting the controller pass the model to the view. Are there other techniques to let a view access a model without the controller being involved? Or is it perfectly fine to let a controller pass the model to a view, so that the view can be build based on the models attributes?

If a view needs to acces data from a model, do you think the controller should:

a) pass the model to the view
b) pass the data of the model to the view
c) neither; it shouldn't be the controllers concern. Let the view access the model directly to retrieve the data. Only let the controller give some parameters the view needs to filter the data from the model.
d) it depends on the situation.
e) none of the above, but [...]

Thanks

After some debate in the comments to an answer that was deleted by the user, maybe this needs clarification. My view of the MVC architecture is biased towards that of the Zend Framework (php) in which an action in a controller by default has a default view assigned to it. So it's not so much the model that dictates which view is approporiate, but rather the controller. Do you feel the model should dictate what view is appropriate? The only way I see fit to let the view be build based on a model, is by letting the controller pass the model to the view. Are there other techniques to let a view access a model without the controller being involved? Or is it perfectly fine to let a controller pass the model to a view, so that the view can be build based on the models attributes?

Bounty Ended with Iain Galloway's answer chosen by Decent Dabbler
edited tags; edited tags; edited tags
Link
skaffman
  • 404.5k
  • 96
  • 825
  • 775
added 224 characters in body
Source Link
Decent Dabbler
  • 22.8k
  • 11
  • 77
  • 107

If a view needs to acces data from a model, do you think the controller should:

a) pass the model to the view
b) pass the data of the model to the view
c) neither; it shouldn't be the controllers concern. Let the view access the model directly to retrieve the data. Only let the controller give some parameters the view needs to filter the data from the model.
d) it depends on the situation.
e) none of the above, but [...]

Thanks

After some debate in the comments to an answer that was deleted by the user, maybe this needs clarification. My view of the MCV architecture is biased towards that of the Zend Framework (php) in which an action in a controller by default has a default view assigned to it. So it's not so much the model that dictates which view is approporiate, but rather the controller. Do you feel the model should dictate what view is appropriate? The only way I see fit to let the view accessbe build based on a model, is by letting the controller pass the model to the view. Are there other techniques to let a view access a model without the controller being involved? Or is it perfectly fine to let a controller decide what model to pass the model to a view, so that the view can be build based on the models attributes?

If a view needs to acces data from a model, do you think the controller should:

a) pass the model to the view
b) pass the data of the model to the view
c) neither; it shouldn't be the controllers concern. Let the view access the model directly to retrieve the data. Only let the controller give some parameters the view needs to filter the data from the model.
d) it depends on the situation.
e) none of the above, but [...]

Thanks

After some debate in the comments to an answer that was deleted by the user, maybe this needs clarification. My view of the MCV architecture is biased towards that of the Zend Framework (php) in which an action in a controller by default has a default view assigned to it. The only way I see fit to let the view access a model, is by letting the controller pass the model to the view. Are there other techniques to let a view access a model without the controller being involved? Or is it perfectly fine to let a controller decide what model to pass to a view?

If a view needs to acces data from a model, do you think the controller should:

a) pass the model to the view
b) pass the data of the model to the view
c) neither; it shouldn't be the controllers concern. Let the view access the model directly to retrieve the data. Only let the controller give some parameters the view needs to filter the data from the model.
d) it depends on the situation.
e) none of the above, but [...]

Thanks

After some debate in the comments to an answer that was deleted by the user, maybe this needs clarification. My view of the MCV architecture is biased towards that of the Zend Framework (php) in which an action in a controller by default has a default view assigned to it. So it's not so much the model that dictates which view is approporiate, but rather the controller. Do you feel the model should dictate what view is appropriate? The only way I see fit to let the view be build based on a model, is by letting the controller pass the model to the view. Are there other techniques to let a view access a model without the controller being involved? Or is it perfectly fine to let a controller pass the model to a view, so that the view can be build based on the models attributes?

edited tags
Link
skaffman
  • 404.5k
  • 96
  • 825
  • 775
Loading
added 564 characters in body
Source Link
Decent Dabbler
  • 22.8k
  • 11
  • 77
  • 107
Loading
Bounty Started worth 150 reputation by Decent Dabbler
Source Link
Decent Dabbler
  • 22.8k
  • 11
  • 77
  • 107
Loading