I need someone who can explain MVC concept to me like a layman.
For further actions, you may consider blocking this person and/or reporting abuse
I need someone who can explain MVC concept to me like a layman.
For further actions, you may consider blocking this person and/or reporting abuse
Samuel Rouse -
Raja Yadav -
Clara Situma -
Arafat Hossain Ar -
Top comments (8)
It's the idea of separating pieces of logic in the presentation layer (i.e. user interface) part of your code to make their responsibilities more clear. The view is the part of the code that actually shows the user interface. For example, it might be a form the user fills out. The model is where the data for the form is actually stored while the user is filling the form out. The controller manages the interaction between the view and the model. In other words, it picks up the user typing into the view component and tells the model to update itself with that content. There are some variations, but the basic idea of separating these types of things out when coding user interfaces tends to be a very common pattern.
Thanks so much @nestedsoftware
So M Stands for models: "Data storage, more like the database."
V stands for views: "What is displayed to the user interface"
C stands for controllers : "Like a middle man between views and models."
So this are what I need to focus on for creating an API?.
I think MVC is more common on the front-end (e.g. code that runs in the browser). On the server side it is used by frameworks like Spring MVC that display the user interface as JSP pages from the server, but less so for cases where the front end is a React application (or some other type of single-page-application, aka SPA, such as Angular)... To implement a back-end API REST endpoint, I don't think you'd use MVC...
Okay, got it fully well.
Thanks for your time.
You can use an API to read data from the view or update the view with new data. The API is the code that can connect to the view as well as connect to the data store for CRUD (Create, Read, Update and Delete) operations.
I asked ChatGPT.
Okay, here's a simple way to explain MVC to a five-year-old:
MVC is like a game where you have three different characters, each with a special job to do.
Together, the Model, View, and Controller characters make up a team that can help each other out and make sure the game is fun and works well. That's kind of like how MVC works in a computer program. It helps to keep things organized and working together, so that the program can do what it's supposed to do.
MVC stands for Model-View-Controller. It's a way of organizing the different parts of a program, like a game or an app. The model is the part of the program that holds the information and data, like a list of words in a dictionary app.
The view is the part that shows the information to the person using the program, like the screen of your phone that shows the words in the dictionary app.
The controller is the part that helps the model and the view talk to each other, and makes sure that everything works together smoothly.
So, MVC is like a team of three friends who all have different jobs to do, but they work together to make the program run well.
MVC is like playing with toy cars!
You have a toy car (the Model) that you can push around and make it move. You also have a remote control (the Controller) that tells the car what to do.
Now imagine you want to make a cool race track (the View) to show off your toy car to your friends. You can use a big piece of paper to draw the track and put some obstacles on it, so your friends can see your car racing around.
So, in MVC, the Model is your toy car, the Controller is your remote control, and the View is the cool race track you made. Just like you can play with your toy car using the remote control and show it off on the race track, developers use MVC to make programs work and look good for users!