The model-view-viewmodel-controller software architecture pattern answers the question how to work with modular programming in systems that use JIT dependency injection. This pattern is based upon model–view–viewmodel architecture while borrowing the “widgetization” concept from Hierarchical model–view–controller.
This document will describe:
The role of a controller is to handle input from a view model or another controller. Controllers will manipulate and verify the data before passing it to a model.
The role of a model is to manage a state.
The role of a view model is to handle input from the view or a controller.
The view is the structure, layout, and appearance of what a user sees on the screen.
The basic structure diagram showcases the hierarchy and flow of communication between a controller, its model, its view models, and their views. Note that view models do not require a parent controller and can be self instantiated.
The expanded structure diagram showcases the hierarchy and flow of communication between two controllers, where one controller has children. Note that view models can have child view models and that data only flows from the parent view model to the child view model. Any communication up the hierarchy is passed directly to the parent controller.