---
title: "Need and use of MVC in frameworks"
subject: "Web Technology"
chapter: 5
key: "semester_7/web_technology:mvc-need-and-use"
source: https://www.bctengineer.com/q/semester_7/web_technology/mvc-need-and-use
site: BCT Engineering
---

# Need and use of MVC in frameworks

Web Technology · Chapter 5: Web applications

- Asked in: 2074 Asoj, 2+6 marks
- Video: [What Is MVC? Simple Explanation](https://www.youtube.com/watch?v=pCvZtjoRq1I) — Traversy Media
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/web_technology/mvc-need-and-use
- Whole chapter: https://www.bctengineer.com/md/semester_7/web_technology/chapter-5

## Question

What is MVC (Model-View-Controller)? Explain the need and use of MVC in web application framework.

## Short answer

MVC separates data, UI, and logic, preventing spaghetti code. It enables parallel team work, maintainability, testability, and reusability; frameworks like Laravel and Django implement routing, ORM, and templates following MVC.

## Answer

#### MVC
**Model-View-Controller** is an architectural pattern that separates an application into three parts: the **Model** (data and business logic, database access), the **View** (user interface / output) and the **Controller** (handles requests, coordinates model and view).

```text
Request -> Controller -> Model (DB)
              |             |
              +---> View <--+  -> HTML response
```

#### Need for MVC in web application frameworks
- **Separation of concerns:** Without it, HTML, SQL and logic get mixed in one page (spaghetti code) that is hard to change.
- **Team work:** Designers edit views, back-end developers edit models and controllers at the same time.
- **Maintainability:** A change in the database or business rules affects only the model; a change in design affects only the view.
- **Testability:** Models and controllers can be unit-tested without the UI.
- **Reusability:** One model can serve several views (web page, mobile app, JSON API).
- **Scalability and organisation:** A standard project structure makes large applications manageable.

#### Use of MVC in frameworks
Frameworks such as Laravel, Django (MTV), Ruby on Rails, Spring MVC, CodeIgniter and ASP.NET MVC implement MVC. They provide:
1. **Routing** that maps a URL to a controller action (`/products/5` -> `ProductController@show`).
2. **ORM / Model classes** that talk to the database (`Product::find(5)`).
3. **Template engines** for views (Blade, Jinja, JSP).
4. **Built-in helpers** for validation, sessions, security and form handling.

Example: a request to `/students` calls `StudentController.index()`, which asks the `Student` model for all rows and passes them to the `students.html` view, which displays a table.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What problem does MVC's separation of concerns avoid?
   A. Browser incompatibility
   B. Slow network connections
   C. Lack of a database
   D. HTML, SQL and logic mixed in one page, making it hard to change
   Answer: D. Without MVC, mixed HTML, SQL and logic become spaghetti code that is hard to maintain. (Key point: Spaghetti code)

2. If the database structure changes, which MVC part is mainly affected?
   A. View
   B. Model
   C. Controller only
   D. None
   Answer: B. Changes in database or business rules affect only the model; design changes affect only the view. (Key point: Maintainability)

3. How does MVC support reusability?
   A. One model can serve several views such as a web page, mobile app or JSON API
   B. It forces one view per application
   C. Each view needs its own copy of the model
   D. Controllers are copied into views
   Answer: A. A single model can feed many different views. (Key point: Reusability)

4. In an MVC framework, what does routing do?
   A. Stores data in the database
   B. Maps a URL to a controller action
   C. Renders the HTML template
   D. Encrypts the session
   Answer: B. Routing maps a URL such as /products/5 to a controller action like ProductController@show. (Key point: Routing)

## Related in Web Technology

- [Web application framework, advantages, MVC](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Aweb-app-framework-mvc) — Web Technology, chapter 5
- [Model View Controller (MVC) pattern](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Amvc-pattern) — Web Technology, chapter 5, asked 2×
- [CMS and difference from web framework](https://www.bctengineer.com/question.md?key=semester_7%2Fweb_technology%3Acms-vs-framework) — Web Technology, chapter 5

## Related in other subjects

- [Application framework versus component reuse](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Aframework-vs-component-reuse) — Software Engineering, chapter 5
