By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,737 Members | 1,934 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,737 IT Pros & Developers. It's quick & easy.

OO wonders

P: n/a
hi

I'm using the model view controller to develop an application

each class of the controller package (FileController, ArticleController)
has the main controller (Controller) as a member.

The controller has the DbAccess object as a member

which means that when I need to call the a method of the DbAccess from a
controller class, it looks like that :

$this->oController->oDbAccess->fetchArray(...) for example.

Now my question is, is that a problem for the performance of the
application. Should I declare the Controller and the DbAccess as GLOBAL
variables or doesn't it matter ? I prefer to avoid using GLOBAL, I think
it's ugly, but would be happy to use it if it's good for the speed of
the code.

Since php is not fully object oriented, I'm sometimes wondering if
designing it Java or Python style is not a bad idea.

Any comment appreciated !

thanks

.b
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi odel!

On Tue, 21 Oct 2003 13:05:03 +0100, odel <b@twin-pix.com> wrote:
hi

I'm using the model view controller to develop an application

each class of the controller package (FileController, ArticleController)
has the main controller (Controller) as a member.

The controller has the DbAccess object as a member

which means that when I need to call the a method of the DbAccess from a
controller class, it looks like that :

$this->oController->oDbAccess->fetchArray(...) for example.

Now my question is, is that a problem for the performance of the
application. Should I declare the Controller and the DbAccess as GLOBAL
variables or doesn't it matter ? I prefer to avoid using GLOBAL, I think
it's ugly, but would be happy to use it if it's good for the speed of
the code.


You can use a singleton object instead of a global.

something like:

class mediator {

function &project_instance(){

static $instance;

if (!isset($instance)){
$instance = new project();
}

return $instance;
}
}

$x =& mediator::project_instance();

This will give you always the same object, without using global.

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.