Welcome Guest, Not a member yet? Register   Sign In
MVC structural advice - separation of code
#5

[eluser]Myles Wakeham[/eluser]
Hi Lyon,

Think of it this way....

M (Model) = The representation of persistent data to your application. Although many will simply say this is the place where you put all of your database queries, SQL, etc. its really more than that. Its where you reference the business objects that your application works on, and includes transforms, etc. to those objects. So in direct response to your question, your 'Project' class is defined in the Model, along with its Get/Set methods, properties, save/load/delete logic, etc. And you would want to do this in such a way that it works to your business requirements (ie. if you ever plan on changing out the type of database you are storing persistent data in, then code it accordingly in the model - ie. MySQL vs. PostgreSQL, Firebird, etc.).

V (View) = The template layer for content. This is like a Smarty template if you are familiar with those. Its an abstraction of the web pages to be displayed but supports template logic.

C (Controller) = The API/Interface code. This is where all user or system events come into your system, are processed and dispatched accordingly. Think of it like a Butler at a restaraunt. You order to the kitchen for your food, but your entire interface to the cooks is through a Butler. The Controller acts in this capacity regardless of what type of interface you are working with (ie. HTML page, AJAX request, etc.). The controller polices the business and security rules on your behalf before allowing your request to hit the Models that do the transforms, etc.

--
I hope this helps clear up where things go for you. Good luck!

Myles


Messages In This Thread
MVC structural advice - separation of code - by El Forum - 06-15-2010, 02:31 PM
MVC structural advice - separation of code - by El Forum - 06-15-2010, 06:07 PM
MVC structural advice - separation of code - by El Forum - 06-16-2010, 07:32 AM
MVC structural advice - separation of code - by El Forum - 06-16-2010, 07:37 AM
MVC structural advice - separation of code - by El Forum - 06-16-2010, 09:11 AM
MVC structural advice - separation of code - by El Forum - 06-16-2010, 03:00 PM
MVC structural advice - separation of code - by El Forum - 06-16-2010, 03:07 PM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 06:09 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 06:24 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 09:29 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 11:05 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 11:09 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 11:16 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 11:25 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 11:51 AM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 12:25 PM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 12:55 PM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 01:03 PM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 01:29 PM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 01:50 PM
MVC structural advice - separation of code - by El Forum - 07-22-2010, 02:29 PM
MVC structural advice - separation of code - by El Forum - 07-01-2012, 09:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB