Looking at MVVM’s core components
MVVM provides a very clear way to separate UI from business logic, promoting code reusability, maintainability, and testability while allowing flexible UI design and changes.
Having business logic living in the code-behind quickly becomes challenging as applications grow in size and complexity. Code-behind refers to the practice of placing the business logic within the same file as the user interface elements, often resulting in a significant amount of code being invoked through event handlers. This frequently results in a tight coupling between UI elements and the underlying business logic, as UI elements are directly referenced and manipulated within the code. As a result, making adjustments to the UI and performing unit testing can become more difficult. Later on in this chapter, in the MVVM in action section, we will see what it means to have business logic in the code-behind and how that complicates maintainability, testing, et cetera...