I believe one of the main benefits of MVVM is decoupling, the binding and lack of references makes things a lot more reusable.
All MVVM examples I find have some kind of View with a ViewModel with the same naming like ExampleView
has a ExampleViewModel
. And always a one to one relationship, one View, one ViewModel.
But in my current project I have a form to be filled so data can be added to the data base, also the user has the option to edit the data on the data base, so this form View can be used transparently with two different ViewModels, one for adding data and one for editing data. I find it a little stupid to copy and paste and entire View just to have it named after its ViewModel, and not only that, if I need to change something, it will always have to be twice the work and stuff might be forgotten.
Some frameworks have a ViewModel locator that will use this same naming convention to bind the View with the ViewModel automatically, and this makes me question the reusability of Views with many different ViewModels.
My question basically is: Is it there a problem in using one View with different ViewModels? Is it bad practice? Are there any naming conventions to this particular situation?
The lack of examples on reusability makes me question the validity of this practice.