e) None of the above; go to the optimized for viewing "ViewModel".
Example in ASP.NET MVC: -
public ActionResult Details(int id)
{
Product p = ProductService.GetProductById(id);
if(p == null) { return RedirectToAction("Index"); }
ProductViewModel model = new ProductViewModel(p);
return View(model);
}
both a) and b) “will do” in accordance with d). Never c).
Typically, a ViewModel simply encapsulates a model (if nothing complicated happens, your view can access the model directly through ProductViewModel.Product). If, however, the view needs to do something complex with the model, the responsibility for this should rest with the ViewModel, and not with the responsibility of the Controller or View.
. , ( , ), , , . . , . (, , , , ..), ViewModels, , , eachother. :)
: -
http://www.thoughtclusters.com/2007/12/datamodel-and-viewmodel/
http://stephenwalther.com/blog/archive/2009/04/13/asp.net-mvc-tip-50-ndash-create-view-models.aspx
http://www.nikhilk.net/Silverlight-ViewModel-MVC.aspx
, ViewModels - .NET, , PHP.
, .