Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1027229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:12:34+00:00 2026-05-16T12:12:34+00:00

I’ve been learning about the Model-View-Controller paradigm (MVC), but I’m quite confused since some

  • 0

I’ve been learning about the Model-View-Controller paradigm (“MVC”), but I’m quite confused since some tutorials contradict other tutorials.

My current understanding of the process looks something like this:

Router / Dispatcher / Front Controller:

  • Though not specifically referenced in the “MVC” name, the Router is still a very important part. It is here that requests are translated from raw URLs to a specific controller. For example, routing a request for http://www.StackUnderflow.com/question/123 to the “Question” Controller of the application.

Model:

  • This is where raw data is collected from some storage source, such as a database or XML file. The model serves as an abstraction layer, translating the Controller’s request for specific data into (for example) an SQL query, and translating the query results into a standard format like a data object.

  • For example, in the /browse/all scenario stated above:

    • The “Question” Controller would ask the Model “Please give the data for question 123.”
    • The Model would then translate that into “SELECT * FROM Questions WHERE Id = 123;” and punt it to the database
    • The database would return a “Question” record to the Model.
    • The Model would take the record, and translate it into a Question data object
    • The Model then asks does the same thing “SELECT * FROM Answers WHERE QuestionID = 123;” and creates an array of Answer objects from the resultset, and adds that to the Question object’s answers member variable.
    • The Model would return the Question object to the “Question” Controller.

Controller:

  • This is the real workhorse of the application. In addition to relaying messages back and forth to the Model and the View, the Controller is also responsible for things like Authorization and application/”business” logicEdit: Per answer, business logic belongs in the Model.

  • In the ongoing example, the Controller wold be responsible for:

    • Ensuring the user is logged in.
    • Determining the QuestionId from the URL.
    • Determining which View to use.
    • Sending HTTP codes and redirecting if needed.
    • Asking the Model for data, and store needed data in member variables.

View:

  • By and large, the View is the simplest part of the application. It mostly consists, in a basic application, of HTML templates. These templates would have placeholders to insert data into the template from the Controller’s member variables:

e.g.

<html>

  <head>
    <title>
      <?php $question->getTitle() ?>
    </title>
  </head>

  <body>
    <h1> <?php $question->getQuestionText(); ?> </h1>
    <h2> Answers: </h2>
    <div class="answerList"> 
      <?php formatAnswerList($question->getAnswers()); ?> 
    </div>
  </body>

</html>
  • The View would also contain methods to format data for delivery to the user. For example, the formatAnswerList() method above would take an array of answers, taken from the Controller, and loop through them while calling something like include $markupPath . "/formatAnswer.inc" which would be a small template of just an answer container.

Questions:

  • Is this view of MVC fundamentally accurate?
  • If not, please carefully explain which components are misplaced, where they should actually go, and how they should properly interact with the other components (if at all).
  • How many classes are used to describe this? In my example there are four objects – one each for the three components of MVC and one that simply stores related data for transmission. Is this normal, or should some be combined. If so, which ones?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:12:34+00:00Added an answer on May 16, 2026 at 12:12 pm

    I think this description puts too much weight on the controller and not enough on the model. The model is ideally where the business logic resides. The controller is really just an interface for the user of the site, routing control where it needs to go. Take a look at a previous discussion on the topic:

    Understanding MVC: Whats the concept of "Fat" on models, "Skinny" on controllers?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.