I have a single View being sent a ViewModel with 20 properties. Now there is a requirement to split the single page into 10 pages, each with 2 properties. My initial gut feeling was to cut the ViewModel up into 10 smaller VMs with 2 properties each, but then I thought, does it matter if 10 different Views all share the same ViewModel and just use the properties they need? I feel like that's the wrong approach but I can't really think of why...
问问题
72 次
1 回答
1
Go with your gut and break it into 10 pieces. Leaving it as-is is certainly the easy way out, but will cause headaches down the road as the site grows/morphs. The MVC gods didn't intend for us to have a huge ViewModel lurking around that pages pick pieces off as needed. Stay tightly-coupled.
于 2013-03-30T03:12:57.633 回答