Definition
MVC separates application into three components: Model, View, and Controller. The Controller handles user input and coordinates Model-View updates.
flowchart LR subgraph View V[View] end subgraph Controller C[Controller] end subgraph Model M[Model] end V -->|user input| C C -->|updates| M M -->|data| C M -.->|notifies| V C -->|formats data| V
Flow
- View receives user input, notifies Controller
- Controller updates Model based on user input
- Model sends updated data back through the chain (active view)
View Types
There are two types of View depending on how it interacts with Model:
Passive View
- View gets data only through the Controller
- View is not aware of Model
- Controller acts as the sole mediator
Active View
- Model notifies View of changes
- View queries Model for updated data
- Controller only handles input events
Disadvantages
- Controller becomes bloated as complexity grows
- Tight coupling between Controller and View in some implementations