hi,
been reading this article: http://www.phppatterns.com/docs/design/ ... er_pattern
and looking at the example between the ProductView and ProductController classes, I am not convinced why there is the need to create the ProductController class extending the ProductView class, only because of the modified constructor.
MVC question
Moderator: General Moderators
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
MVC question
Last edited by harrisonad on Wed Dec 28, 2005 6:23 pm, edited 1 time in total.
Re: MVC question
Ok.harrisonad wrote:[...] I am not convinced why there is the need to create the ProductController class extending the ProductView class, because of the modified constructor.
Where's the question?
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
Thanks, alvin for serious reponse. Lot of jokers have been sticking to this forum ever since.
Well, the word separated always confused me since the controller, as in that example, depends on the view for its methods and properties.
My first though of MVC ppattern is that these components (models,views and controller) got stand-alone classes, rendering the thought of separation.
Is it?
Well, the word separated always confused me since the controller, as in that example, depends on the view for its methods and properties.
My first though of MVC ppattern is that these components (models,views and controller) got stand-alone classes, rendering the thought of separation.
Is it?
This is what threw me when I first looked at MVC.
Whilst the term is separation - it is not a dictionary definition.
Separation in MVC means using objects to create common paths and methods (aka patterns) to achieve a goal.
e.g. - a data source object.
Now, a mysql class for example, is not going to be able to do much at all in stand alone, but it allows the logic developer to have easy to use methods to gain access to data:
Now.. this is where the Separation comes into it - what if, for example, the hosting company switches databse software to Oracle?
Well - the Logic Developer will not have a huge amount to change - apart from any RDBMS specific SQL, hardly anything at all:
So providing both classes share method names, then the logic developer will only have to change the object class, and that is it.
So as you can see, this will allow the developer of the data object and the logic developer to work independantly of one another - if the data object needs tweaking or a huge revamp, this can be done without the logic code being changed at all and vice versa.
Whilst the term is separation - it is not a dictionary definition.
Separation in MVC means using objects to create common paths and methods (aka patterns) to achieve a goal.
e.g. - a data source object.
Now, a mysql class for example, is not going to be able to do much at all in stand alone, but it allows the logic developer to have easy to use methods to gain access to data:
Code: Select all
<?php
$db = new MySQLClass();
$db->connect('host', 'user', 'pass', 'db');
$rows = $db->fetch('SELECT * FROM `table`');
?>Well - the Logic Developer will not have a huge amount to change - apart from any RDBMS specific SQL, hardly anything at all:
Code: Select all
<?php
$db = new OracleClass();
$db->connect('host', 'user', 'pass', 'db');
$rows = $db->fetch('SELECT * FROM `table`');
?>So as you can see, this will allow the developer of the data object and the logic developer to work independantly of one another - if the data object needs tweaking or a huge revamp, this can be done without the logic code being changed at all and vice versa.