DEV Community

Anja
Anja

Posted on

5

What is a Model View Controller?

Let`s have a look at MVC, the Model View Controller. MVC is a design pattern for web applications. It consists of these three components:

  1. Model: The model holds all the data, state and application logic. It provides an interface to manipulate and retrieve its state. It responds to requests of the View and instructions of the controller. It also informs the View about state changes.

  2. View: The View receives all the data it needs and displays it in a User Interface. The View can request state information from the model.It also "talks" to the controller by e.g. informing it that the user pressed a button.

  3. Controller: The controller controls the interactions between the model and the view. It sends instructions to the model to change its state based on what has happened (e.g. pressing a button) and requests the view to change its display.

Have you used the MVC yet?

Top comments (2)

Collapse
 
jimcmorrison profile image
JimCMorrison β€’

Nice quick knowledge share Anja! My first entanglement with MVC was with Ruby on Rails. I have a lot of nostalgia for working with Rails but not something I play with much these days. What was your first experience with MVC?

Collapse
 
anja profile image
Anja β€’

Hi Jim! That's great! 😊 I didn't try Ruby on Rails yet. This blogpost of mine is old and transfered from my WordPress, so I don't remember if I only read the theory about MVC back then or did try it already. πŸ˜„

Cloudinary image

Video API: manage, encode, and optimize for any device, channel or network condition. Deliver branded video experiences in minutes and get deep engagement insights.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay