0

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

Can O' Spam
  • 117
  • 4
  • @gnat, I have looked at that one and it didn't really help me, love the answers, just couldn't understand it very much – Can O' Spam 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 – Can O' Spam Oct 21 '15 at 15:07
  • 1
    @SamSwift have you read [this answer](http://programmers.stackexchange.com/a/176281/52929) 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 – Can O' Spam 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

1 Answers1

3

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.

FLSH
  • 159
  • 1
  • 6