MVC MVP MVVM Flashcards
What are the three major components of the MVC design pattern?
Model – Handles business logic and data.
View – Displays UI (XML, HTML).
Controller – Processes user input and updates Model/View.
How does the View in MVC observe changes in the Model?
Through the Observer pattern (Model notifies View of state changes).
What is the key difference between MVC and MVP?
MVC: Controller handles input logic.
MVP: Presenter replaces Controller and communicates with View via an interface (decouples View logic).
Why is MVP easier to unit test than MVC?
Because the View and Presenter are decoupled via interfaces, allowing mock Views for testing.
What is the role of the Presenter in MVP?
Receives user input from View.
Processes data using Model.
Returns results to View via interface.
What is the key feature of MVVM that distinguishes it from MVC/MVP?
Two-way data binding (automatic sync between View and View-Model).
How does the View-Model in MVVM communicate with the View?
View references View-Model.
View-Model exposes properties/commands but has no reference to the View.
Changes propagate via data binding or observer pattern.
True or False: In MVVM, one View-Model can be mapped to multiple Views.
True (Many-to-one relationship).
Which pattern is best for apps requiring bi-directional data binding?
MVVM (e.g., Android Data Binding, Jetpack Compose).
Compare the communication flow in MVC, MVP, and MVVM.
MVC: User → View → Controller → Model → View.
MVP: User → View → Presenter (via interface) → Model → Presenter → View.
MVVM: User ↔ View ↔ View-Model (binding) ↔ Model.