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

  • SEARCH
  • Home
  • 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 538755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:03:53+00:00 2026-05-13T10:03:53+00:00

I hope this isn’t too subjective. I can’t decide between these two design opportunities.

  • 0

I hope this isn’t too subjective. I can’t decide between these two design opportunities.

I have a Front Controller pattern. When the user surfs to a specific URL, my framework loads a specified View Controller for this URL. The View Controller then calculates some things and loads a View Template, to show the results.

Now imagine you wanted to make a site like SO. Every page looks pretty similar: Same header, same menu, same footer. Just the content area is different. You surf to the “Ask Question” page, and want the “Ask new Question” form to come up inside the layout.

So we make a RootViewController with a RootView template that sets up the layout and has a placeholder for the content. And a AskQuestionViewController with an AskQuestionView template.

Our Front Controller loads the AskQuestionViewController class. The system calls the loadView() method, and then the viewDidLoad() method.

Option A: AskQuestionViewController inherits from RootViewController.

method gets called by the system, and calls parent::loadView() first. So RootViewController gets the chance to create its RootView template. Next, loadView() loads the AskQuestionView template, and assigns it to the content placeholder of the RootView template.

Option B: AskQuestionViewController does not inherit from RootViewController.

The loadView() method of AskQuestionViewController loads RootViewController first. Then it loads its own AskQuestionView template, and assigns it to the content placeholder of the RootView template.

The only differences between these View Controllers are, that they load different View templates, and that they have different custom methods to perform certain tasks. i.e. the RootViewController is able to compose the Navigation Menu and highlight what’s currently visited. There’s nothing else in RootViewController that could be useful for AskQuestionViewController.

Which Option would be better design?

  • 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-13T10:03:53+00:00Added an answer on May 13, 2026 at 10:03 am

    The prefer composition over inheritance principle suggests B is preferable.

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

Sidebar

Related Questions

I hope this isn't too difficult, obviously you can call HTML tags such as
OK I hope this isn't too specific. I have a database driven CMS that
I hope this isn't too specific. I have created an XML Schema which i
I hope this isn't too simple, but I have a report retrieves rows using
I hope this isn't too off topic for this forum, but I have been
Alright, I hope this isn't too broad a question but my curiosity got the
Hey guys, hope this isn't too much of a n00b question I'm mainly a
I hope this question isn't too open ended, but a nudge in the right
I'm trying to get this to work and I hope this isn't too vague.
I've seen a few questions dancing around this, so I hope this isn't too

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.