As I've been learning WPF, I've been concentrating on applying only the MVVM pattern to applications.
However, I notice that for some functionality such as validation, it is difficult or impossible to remain true to the MVVM model. Many times simply sticking an x:Name on an element and changing it in code-behind event-handler solves the problem immediately.
What real world experience do you have with abandoning the MVVM pattern?
MVVM creator John Gossman points out that implementing MVVM is "overkill" for simple UI operations, and that for larger applications, generalizing the ViewModel becomes more difficult. There is considerable memory consumption with data binding in very large applications.
For trivial projects MVVM is unnecessary. Using only the View is sufficient. For simple projects, the ViewModel/Model split may be unnecessary, and just using a Model and a View is good enough. Model and ViewModel do not need to exist from the start and can be introduced when they are needed.
Disadvantages of MVVM Model:This can confuse the developer and make the development or debugging process complicated. When it comes to an Android environment, the user is restricted with only two ways to work with View. Moreover, they can either use Data Binding or any other View method.
The Windows Presentation Framework (WPF) takes full advantage of the Model-View-ViewModel (MVVM) pattern. Though it is possible to create WPF applications without using the MVVM pattern, a little investment in learning can make building WPF applications much simpler.
I think code-behind is fine if it's view related only. It doesn't break MVVM because it's the separation of the layers what is important. If your VMs stay unaware of the Views, then I don't think it matters if you used XAML or code. You try to minimize code-behind because it's usually cleaner and easier to do in XAML, but sometimes a few lines of code are cleaner than a lot of XAML. For example, binding all the keys of the keyboard. You can type 101 key bindings in XAML or 5 lines of code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With