What does the MVC pattern separate?
Options
- Model (data), View (screen) and Controller (input handling) (Correct option)
- Memory, Value and Cache, as the three layers of a program
- Main, Variable and Class, as the three parts of a file
- Method, Variable and Compiler, as the parts of a program
Answer
Model (data and rules), View (what the user sees), Controller (receives input and coordinates)
Why
MVC splits an application into:
- Model: the data and business rules.
- View: the presentation (HTML page, JSON).
- Controller: handles the user's request, calls the model and chooses the response.
Spring MVC follows it: @Controller classes, services/entities as the model, Thymeleaf/JSON as the view. The goal: change the UI without touching the rules and vice versa.
Remember
MVC = model, view, controller separation.