Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

MVC: View vs Controller responsibilities?

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:

  1. The view intercepts the mouse click, adds a copy of the item to the cart, then notifies the controller which item was added.
  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...