jeudi 11 mars 2021

MVVM View Model Organization

Making my first WPF MVVM application and I have a question about the organization of View Models. I have a ClassA with a one to many relationship with ClassB

[Class relationship][4] [4]: https://ift.tt/2OmliLu

I want the main view to look like this. It contains some info from class A along with a listview of all Class B instances that are associated with Class A

[Desired Main View][1] [1]: https://ift.tt/2ONybOn

I have come up with two approaches but I am unsure about which organization, if either, is considered the best approach. (This is a standard CRUD application: I want to be able to modify Class A, Add and remove Class B from Class A, modify Class B)


Approach 1 The main view model contains a ClassAViewModel and a List of ClassBViewModels

[Approach 1][2] [2]: https://ift.tt/2Nbuphy


Approach 2 The main view model contains a ClassAViewModel. The ClassAViewModel handels its own list of ClassBViewModels

[Approach 2][3] [3]: https://ift.tt/3l8RFZS


I would greatly appreciate any input on which approach will be best for me / a new approach. I'm also open to any recommendations of resources that would help me better understand software design and best practices in general

Aucun commentaire:

Enregistrer un commentaire