# Design Patterns
# Model View Controller
Traditionally used for desktop graphical user interfaces (GUIs), this pattern has become popular for designing web applications.


# Controller
- Handles clients request
 - Not much code
 - Asks model for information
 - Handles failure and success
 
# Model
- Handles data logic
 - Interacts with database
 
# View
- Handles data presentation
 - Dynamically rendered
 - Only cares about presentation
 
Model and view never interact with each other
Model handles all the data
View handles all the presentation
Controller just tells what to do
# Example) blog post
- Web browser or client sends the request to the web server, asking the server to display a blog post.
 - The request received by the server is passed to the controller of the application.
 - The controller asks the model to fetch the blog post.
 - The model sends the blog post to the controller.
 - The controller then passes the blog post data to the view.
 - The view uses blog post data to create an HTML page.
 - At last, the controller returns the HTML content to the client.
 
# Model View View-Model



- Easily understandable
 - Easily extendable
 - Easily testable
 
# Model
- Database
 
# ViewModel
- Business logic
 - Functions.
 
# View
- UI
 - View should not have business logic
 
# Data binding
- View references view-model and checks for change to update itself.
 
← The Clean Code ERD →