This question already has an answer here:

I am trying to understand MVC, but for most of the Q&A's I have seen, the description is great but I cannot quite understand it, I think it works like this scenario I thought of:

User Registration (sorry for the wrong order):

  • Controller: The user, they input the data (username & password)
  • Model: The UserRegistration class - Takes in the username and password and deals with the request
  • View: A success message passed to the user (just an example!)

Am I right in thinking that it goes the same for any language; C#, C++, PHP etc.?

I have tried for ages to understand this and what I am looking for is: talk to me like I am a child or a monkey.

I have looked here (What is MVC, really?) and found it didn't help me

marked as duplicate by gnat, enderland, GlenH7, Robert Harvey, psr Oct 21 '15 at 15:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @gnat, I have looked at that one and it didn't really help me, love the answers, just couldn't understand it very much – Sam Swift 웃 Oct 21 '15 at 15:05
  • The question marked as the answer did not help me, it does not answer my question, I am looking for something very simple and this did not help, sorry – Sam Swift 웃 Oct 21 '15 at 15:07
  • 1
    @SamSwift have you read this answer there? – enderland Oct 21 '15 at 15:08
  • @enderland, I did and it seemed to make some sense, it just didn't quite help me get my head around it as it is such a huge topic – Sam Swift 웃 Oct 21 '15 at 15:09
  • In the past, we used to just call this "programming", but now, everything needs to be labeled, categorized and classified. – Rob Oct 21 '15 at 15:27

As your example of user registration:

  • Model: This would be your "User" class which is populated at the end of registration, that stores the Username, Email, Password, etc. This would then be put into the database.
  • View: The HTML page which allows the user to input their desired Username, Email, Password, and click submit.
  • Controller: Gives the View to the User initially so they can fill out the registration form. Then takes the details from the View, uses them to populate the Model and create a record in the database.

An easy way of looking at it is that the Controller acts as a bridge between Model and View. If you wish to retrieve data from a db, the Controller accesses the Model layer, and passes the data down into the view. If you want to store data, the data you enter into the view is passed to the Controller which runs logic (validation, modification) on the user submitted data, creates the Model using that data, and stores it in the database.

  • So in terms of the Controller, this wouldn't be the user but the server handling the request and giving it to the user? – Sam Swift 웃 Oct 21 '15 at 15:10
  • @SamSwift Exactly – FLSH Oct 21 '15 at 15:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.