Click here to Skip to main content
15,891,607 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: MVVM question: hierarchical model representation Pin
Alisaunder14-Oct-11 1:13
Alisaunder14-Oct-11 1:13 
QuestionRe: MVVM question: hierarchical model representation Pin
Member 103390714-Oct-11 3:53
Member 103390714-Oct-11 3:53 
AnswerRe: MVVM question: hierarchical model representation Pin
SledgeHammer0114-Oct-11 5:01
SledgeHammer0114-Oct-11 5:01 
GeneralRe: MVVM question: hierarchical model representation Pin
SledgeHammer0114-Oct-11 5:47
SledgeHammer0114-Oct-11 5:47 
GeneralRe: MVVM question: hierarchical model representation Pin
SledgeHammer0114-Oct-11 6:30
SledgeHammer0114-Oct-11 6:30 
GeneralRe: MVVM question: hierarchical model representation Pin
SledgeHammer0114-Oct-11 8:07
SledgeHammer0114-Oct-11 8:07 
GeneralRe: MVVM question: hierarchical model representation Pin
SledgeHammer0114-Oct-11 8:22
SledgeHammer0114-Oct-11 8:22 
GeneralRe: MVVM question: hierarchical model representation Pin
Member 103390714-Oct-11 8:00
Member 103390714-Oct-11 8:00 
Thank you guys for all replies. No need to argue, really. To clarify a few points: the project which inspired the question is certainly more complex than counting days in a week (it is actually sports related but I came with the example to spare myself the need to explain the particular sport). It is a non commercial activity of mine and I though that one of the benefits would be to get comfortable with the celebrated MVVM. That is why I overthink things, because in this rare case I can afford it, and I can hardly get a thorough understanding by underthinking.

SledgeHammer's reaction was my reasoning exactly - why complicate things with unneccessary model objects when viewmodel alone does all I need with no further complications. But most design patterns have use for model classes, so I thought there must be a "proper" (whatever it means) way to desing the application with model and viewmodel separated. I'll look into factory classes, thanks for the suggestion.
I never said there is 1:1 correspondence between model and viewmodel classes, on the contrary.

I remember now what made me think about the design the way I described. In one article on MVVM (don't know which one, maybe I read too many) someone said that model classes should contain only data that need to be stored in the data store. In particular, data which can be computed should not be present in the model classes but rather in the viewmodel.
Back to my example - if the Day class contains a DateTime information about the time some employee came to work and another DateTime info when the employee left, it is all you need to store. Then my view wants to show how many hours the employee spend working, which can be computed from the data but it is job (I believe/ed) of the DayViewModel to provide this information. That is why I thought I needed both Day and DayViewModel. I got the impression that model classes store data, viewmodel contains all logic and view deals with appearance.

I don't seek perfect code for the sake of it but I can hardly appreciate the benefits of MVVM for large scale applications if I can't successfully use it (with a bit of overkill) even for a small application.

I'll be happy to hear any other suggestions and advice, H.
GeneralRe: MVVM question: hierarchical model representation Pin
SledgeHammer0114-Oct-11 8:19
SledgeHammer0114-Oct-11 8:19 
GeneralRe: MVVM question: hierarchical model representation Pin
Member 103390714-Oct-11 9:13
Member 103390714-Oct-11 9:13 
QuestionSetting combobox width by binding Pin
Preston Phillips13-Oct-11 10:30
Preston Phillips13-Oct-11 10:30 
GeneralRe: Setting combobox width by binding Pin
Preston Phillips13-Oct-11 10:51
Preston Phillips13-Oct-11 10:51 
GeneralRe: Setting combobox width by binding Pin
Preston Phillips14-Oct-11 8:37
Preston Phillips14-Oct-11 8:37 
QuestionSet DisplayMemberPath For Dynamic Combobox Pin
Matt Tapia11-Oct-11 8:20
Matt Tapia11-Oct-11 8:20 
AnswerRe: Set DisplayMemberPath For Dynamic Combobox Pin
Wayne Gaylard12-Oct-11 1:09
professionalWayne Gaylard12-Oct-11 1:09 
GeneralRe: Set DisplayMemberPath For Dynamic Combobox Pin
Matt Tapia12-Oct-11 4:19
Matt Tapia12-Oct-11 4:19 
GeneralRe: Set DisplayMemberPath For Dynamic Combobox Pin
Alisaunder13-Oct-11 2:46
Alisaunder13-Oct-11 2:46 
GeneralRe: Set DisplayMemberPath For Dynamic Combobox Pin
Wayne Gaylard13-Oct-11 2:59
professionalWayne Gaylard13-Oct-11 2:59 
QuestionWPF Datagrid checkbox property not updated Pin
Preston Phillips11-Oct-11 8:17
Preston Phillips11-Oct-11 8:17 
AnswerRe: WPF Datagrid checkbox property not updated Pin
Wayne Gaylard12-Oct-11 1:11
professionalWayne Gaylard12-Oct-11 1:11 
GeneralRe: WPF Datagrid checkbox property not updated Pin
Preston Phillips12-Oct-11 3:52
Preston Phillips12-Oct-11 3:52 
GeneralRe: WPF Datagrid checkbox property not updated Pin
Preston Phillips12-Oct-11 4:38
Preston Phillips12-Oct-11 4:38 
GeneralRe: WPF Datagrid checkbox property not updated Pin
Preston Phillips12-Oct-11 5:15
Preston Phillips12-Oct-11 5:15 
QuestionValue Conversions Pin
Geysser8-Oct-11 9:04
Geysser8-Oct-11 9:04 
AnswerRe: Value Conversions Pin
Abhinav S9-Oct-11 0:45
Abhinav S9-Oct-11 0:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.