Using MVC
Model:
- Can be accessed by both the View and the Controller
- Can NOT access the View or the Controller
- Suggested Usage:
- Handles business logic
- Interacts with the database
- It processes and responds to data read requests from the View
- It processes data create, update, and delete requests from the Controller
View:
- Only has access to the Model
- Can NOT access the Controller
- Suggested Usage:
- Builds the HTML output string for your web application
- Handle display logic
- When it needs data, it will request it from the Model
Controller:
- Only has access to the Model
- Can NOT access the View
- Suggested Usage:
- Handles all inbound request i.e. Form submissions
- Handles data validation logic
- When it needs to make a change to the database, it will send the validated data to the Model