class effeciency

From: Date: Thu, 28 Feb 2002 08:40:52 +0000
Subject: class effeciency
Groups: php.general 
Request: Send a blank email to php-general+get-86554@lists.php.net to get a copy of this message
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I have an application that spits out a contact form in either English or Danish. Someone suggested I use a 'class factory' like the PEAR db abstraction layer and that is what I'm doing. So I choose the language like this: $form = Form::GetFormObject($lang); //different class for each lang No problem. My question is related to the efficiency of this. It is only the *properties* that are different in each language class not the methods so I'm including all the same methods twice! That doesn't seem terribly efficient. I thought maybe I could init properties with a constructor in a single class like this: <? class test { function test($lang) { if($lang=="en") { var $lang="English"; } else if($lang="dk") { var $lang="Danish"; } } } ?> But it fails. Is there a better way? It just seems like overkill to include 6-700 lines of methods /twice/ Many thanks.... - -- - ----------------------------------------------------------- www.explodingnet.com | Projects, Forums and + Articles for website owners - -- Nick Wilson -- | and designers. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) iD8DBQE8fe0UHpvrrTa6L5oRAgh5AJ9oXAQ4kMwj/neprZOQx1KZmpOWXACdFTiP WAFmmGoE60Y079p39i+pCnQ= =290x -----END PGP SIGNATURE-----

« previous php.general (#86554) next »