MVC Architecture
Formal Definition
MVC (Model-View-Controller) is a design pattern used as an architectural framework that separates the application into three main components — Model, View, and Controller — to manage data, presentation, and user interaction independently.
- Formal Definition
- Working of MVC
- diagram
- Design Principles of MVC
- Features of MVC Framework
- Advantages
- Disadvantages
- MVC in Practical
- map
MVC Architecture Overview
-
MVC stands for Model, View, and Controller.
-
It is a pattern for architectural framework.
-
Divides application into three main parts:
-
Model
-
View
-
Controller
-
1. Model
-
Responsible for managing application data.
-
Responds to requests made from the View.
-
Gives instructions to Controller when updates are required.
Stores data and handles related business logic.
-
Transfers data between Controller and other components.
-
Retrieves/manipulates data from the database (e.g., customer info).
-
Maintains data at the lowest layer of the architecture.
2. View
-
Manages the presentation of data.
-
Presents data in desired format with the help of View.
-
Uses script-based systems like JSP, ASP, PHP, etc.
Represents UI components for data presentation.
-
Uses Observer pattern to stay updated with Model.
-
Collects data from Model to present output to the user.
-
Displays data in forms like charts, tables, diagrams.
-
Contains UI elements (e.g., text boxes, dropdowns) related to the data.
3. Controller
-
Receives input from the user.
-
Validates input before processing.
-
Performs business operations that modify the Model.
-
Responds to user requests and interacts with Model.
First point of contact for user inputs.
-
Processes user requests via Model and passes data to View.
-
Handles user interactions (mouse/keyboard).
-
Sends commands to Model for data updates.
-
Sends commands to View to modify presentation (e.g., scrolling).
Working of MVC
-
User interacts with the browser (Triggers event).
-
Browser sends an HTTP request to the web server.
-
Router receives the HTTP request and directs it to the Controller.
-
Controller communicates with the Model to read/modify data from the database.
-
View receives updated data from the Controller, updates its state, and sends the output to the browser.
Understanding with Flow (Refer Fig. 1.6.1)
-
User interacts with the system.
-
Controller alerts about events and updates Model.
-
Model notifies View when data changes.
a -
View takes Model data and updates the display.
Summary of Components
-
Model — Represents Data.
-
View — Acts as User Interface.
-
Controller — Works as Request Handler.
Design Principles of MVC
-
Divide and Conquer – Components designed separately.
-
Increase Cohesion – Strong layer cohesion by separating View and Controller.
-
Reduce Coupling – Minimal and clear communication between components.
-
Increase Reuse – Reusable UI components; View becomes application-specific.
-
Design for Flexibility – Easy to modify View/Controller for UI changes.
Features of MVC Framework
- Separation of Logic
- Ability to Provide Multiple Views
- Faster Development Process
- Returns Data Without Formatting
- Customization
1. Separation of Logic
-
Separates input logic, business logic, and UI logic.
-
Makes testing and debugging easier.
-
Modification in one part does not affect other parts.
2. Ability to Provide Multiple Views
-
Multiple views can be created for the same data using MVC Model.
3. Faster Development Process
-
Supports rapid and parallel development.
-
One developer can work on the View, while another works on the Controller.
4. Returns Data Without Formatting
-
Returns data in raw format without applying formatting.
-
Same components can be reused with any interface.
5. Customization
-
Extensible and pluggable framework.
-
Components can be replaced or customized easily.
- Easy testability; highly testable, extensible, and pluggable.
- Full control over HTML and URLs in web applications.
- Utilizes frameworks like ASP.NET, JSP, Django.
- Clear separation of logic: Model, View, Controller.
- Supports URL Routing for SEO-friendly URLs.
- Supports Test Driven Development (TDD).
Advantages
-
Easy for beginners to learn and get support.
-
Supports parallel development of multiple modules.
-
Produces SEO-friendly URLs and webpages.
-
Uses Front Controller design pattern for request processing.
-
Easy to maintain and extend code.
-
Allows separate testing of Model component.
-
Simultaneous development of Model, View, Controller.
-
Reduces complexity by splitting application into three units.
-
Independent classes and objects simplify component testing.
Disadvantages
-
Challenging to implement with modern UI designs.
-
Requires many developers for parallel development.
-
Controller business logic needs frequent maintenance.
-
Harder to read, modify, test, and reuse components.
-
Not suitable for small applications.
-
Inefficient data access in View.
-
Navigation is complex due to additional abstraction layers.
-
Increased complexity and inefficient data handling.


















