Junior
Describe the MVC interaction model.
sobes.tech AI
Answer from AI
The architectural pattern that divides an application into three interconnected parts:
- Model: Represents data and business logic. It has no information about View or Controller. It notifies the View of changes in its data (via Observer, Listener).
- View: Displays data from the model and responds to user actions. It contains no business logic and does not interact directly with the Model. It sends requests to the Controller upon user interaction.
- Controller: Acts as an intermediary between the Model and View. It processes user input from the View, updates the Model, and selects the View for display.
Advantages:
- Separation of concerns.
- Improved testability (Model and Controller are tested independently).
- Reusability (especially the Model).
Disadvantages:
- Becomes cumbersome for complex UI (thick controllers - "massive controllers").
- Interaction between View and Model can be confusing (via Controller).
- Tight coupling between View and Controller (in Android, Activity often plays both roles).
In Android, Activity or Fragment often performs functions of both View and Controller, which complicates separation. Pure MVC is rarely used in Android; more common are derivative patterns such as MVP or MVVM.