MVC
MVC
(MVC)
By : Nourhan Abdallah
Agenda
❑ Description
❑ Problem
❑ Solution
❑ Class structure
❑ Example from real life
❑ Sample code
❑ Another example
❑ Pros
❑ Cons
❑ Conclusion
❑ References
Description
MVC solves this problem by dividing the application into three interconnected components:
• Model: Represents the data and business logic of the application. It manages the data, responds to requests
for information, and notifies the views of any changes.The backend that contains all the data logic
• View: Presents the data to the user and handles user interactions. It receives data from the model and
renders it in a user-friendly format. Views also send user input back to the controller for processing. The
frontend or graphical user interface (GUI)
• Controller : Acts as an intermediary between the model and the view. It receives user input from the view,
processes it (often by updating the model), and updates the view accordingly.
This is the Model part of the MVC pattern.Its job is to manage the data, keep
track of the likes, and handle business logic (like updating the number of
likes).It doesn't care about how the data is shown or how the user interacts.
1. Model – Stores post data
2. View – Displays the post and like count
1. Model
Example :
3. Controller
Pros of MVC
1. Easy to Manage
Everything is organized — data, design, and logic are in separate boxes.
2. Easy to Update
You can change the look (View) without touching the logic (Controller) or data (Model).
3. Teamwork Friendly
One person can work on the design, another on the data, and another on the logic — all at the same time.
4. Reusability
You can reuse the same code for other apps or parts of your project.
It can be confusing to understand how Model, View, and Controller work together.
You need to write more code and manage more files than usual.
4.Debugging is Tricky
Since things are separated, it can be harder to find where a problem is coming from.
References
• The Model View Controller Pattern – MVC Architecture and Frameworks Explained