Jump to content

MVC Design Query


Recommended Posts

Hi All,

 

Ok so i know theres loads of php MVC products out there but Im writing my own version of the MVC pattern purely for the learning benefit and so i understand it!  ;D

 

Anyway i have a couple of quick design question in which im looking for the best or most common approach to solve.

 

So the questions are:

 

If my sections are mainly logically separate units e.g. Home, Guestbook, Site News, Users etc with a controller, model and view for each but on the home page i want to display a range of information from each section e.g. latest headlines, latest members, latest posts what is the best way to do this?

 

Theorys i have are:

[*]Bypass each units controllers and go straight to their model e.g. HomeController calls methods in NewsModel returns the data and renders it

[*]Keep it logically separate and write a HomeModel that contains the relevant db calls to the other units

[*]Some other weird and wonderful way i havent though of!  :D

 

And additionally if i have a front controller that is processing and directing all my requests to the required controller which is processing the data and rendering a template what is the best way to process ajax requests?  Am i over complicating and should just have the server side method just echo back to the ajax script or should i append a GET param of callType=ajax and process differently?

 

I know design is never an exact science but am just curious what ideas/suggestions are out there!

 

Cheers all!

Ross

Link to comment
Share on other sites

  • 4 months later...

Ross,

 

With regards to point 1, both the first two points are perfectly acceptable. However, for ease and the fact it's much more flexible, I would bypass the controller and call the model directly returning an array of data to do what you like with.

 

Secondly, I would go down the route of processing ajax requests differently, as if you process them the same then you'll be loading the framework every time when you really don't need to.

 

I hope some of this helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.