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 7531615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:13:12+00:00 2026-05-30T05:13:12+00:00

Ok – I’ve been looking at the MVC design pattern, and need to clarify

  • 0

Ok – I’ve been looking at the MVC design pattern, and need to clarify the way it’s supposed to work. I’ve done lots of reading, but as I’m new to DP’s it’s all fuzzy to me.

In an MVC, the model will handle my database work for me. That seems to be the simplest part.

The controller will handle the processing – dealing with forms, getting data from the model etc.

The problem for me is the view. Let’s say I was looping through a resultset from a database query. When looping through the results, I might need to perform an if/else. Now, typically it seems that would be done within the View – but that seems counter intuitive to me. As soon as you need to start performing checks like that in the View, it seems the view is no longer just for presentation, but for processing logic just like the controller does. I also imagine that this could make for messy code within the View, but that’s a different matter.

So, is the View an ok place to put small bit’s of operation on the code, or is there somewhere else I should be putting that code? I know I could create a class method in a library somewhere else, but that seems like it would over complicate things un-needlessly.

I’ve tagged this with PHP as it’s the primary language I work with.

  • 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-30T05:13:13+00:00Added an answer on May 30, 2026 at 5:13 am

    ASP .NET MVC developer here, but I’m not sure that it matters given the nature of the question.

    I try to think of a view as everything I need to render a particular operation. This will include stuff that is tied to specific business concepts, but also, will cover things like pagination and other concepts that aren’t domain-specific problems, but still require some representation on the page.

    Now, in terms of code operations, in some senses there isn’t a lot you can do. You may have a part of your page that is dependent on, say, a collection being populated and having things in it. I have no real problem sticking in simple conditional constructs to handle things like this. It is code, but you could argue that its not important code. We aren’t performing work per se, merely suppressing the display of certain elements based on the internal state of the view.

    I’d argue that would apply to a lot of simple conditional display logic.

    However, if you find that you are performing stuff that is more complex than that, it’s probably best to change the model to give the view less work to do. e.g. if you’re performing some nasty chained ternary in view-side markup, you may wish to consider encapsulating that logic in the construction of the model, instead of leaving it for the view to sort out.

    So in conclusion, while simple on/off presentational constructs are generally okay (if a little messy) in views, consider creating extra properties etc on your model if you find your view code becoming inordinately complex or unmaintainable.

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

Sidebar

Related Questions

So to start, I have an array of XML files. These files need to
My NSXMLParser breaks on this string: <title>AAA &#8211; BCDEFGQWERTYUIO</title> I parsed it in this
I need to clean up various Word 'smart' characters in user input, including but
I need a function that will clean a strings' special characters. I do NOT
The problem with unsigned char. I am reading a PPM image file which has
I would like to count the length of a string with PHP. The string
I've got the following login script.. <?php $name = $_POST[name]; $password = $_POST[password]; $query
I'm struggling to position the second level of a dropdown nav menu and was
Have a webpage that will be viewed by mainly IE users, so CSS3 is
I'm trying to craft a Java regular expression to split strings of the general

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.