I have a view that shows pictures of items in a store along with an initially empty shopping cart. When the user clicks an item, I want to add it to the shopping cart. I can think of two ways to do this:
- The view intercepts the mouse click, adds a copy of the item to the cart, then notifies the controller which item was added.
- The view intercepts the mouse click, notifies the controller which item was clicked, then the controller adds the item to the user's cart and tells the view to refresh which will show the item added to the cart. This would be a really dumb view.
Conceptually, is one approach better than the other?
Thanks.
question from:
https://stackoverflow.com/questions/65846168/mvc-view-vs-controller-responsibilities 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…