MVC Flashcards

1
Q

Describe the purpose of the model in MVC architecture

A

The model handles data logic and interacts with the database. It receives data from the controller, and then handles validation, saving and deleting. It will then send a response back to the controller i.e. “STATUS CODE 200”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe the purpose of the controller in MVC architecture

A

The controller handles all user input. It will receive a request from the user, and handles the request flow. The controller interacts with both the model and view. It sends requests to the model and handles the response, and sends data to the view to be rendered. The controller should not interact or change the data in any way, this is handled by the model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the view in MVC architecture

A

The view is used to present the information to the user. It is usually a template file that dynamically renders HTML using the information that the controller sends it. It then sends the information back to the controller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

True or false: On a website built with MVC architecture, a user manipulates the model when they create or delete an account

A

False: A user only interacts with the controller. The controller would then send a request to the model to create or delete and account from the database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

True or false: All data logic is handled by the model

A

True. No other component should be interacting with the database (writing, reading, deleting, etc.). All these tasks are handled by the model, and the model communicates with the controller usually with status codes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly