At 01:34 11.06.2003, Sparky Kopetzky said: --------------------[snip]-------------------- >Ok - let the war begin...
no war at all... >Question: Why doesn't the PHP community support using an Hungarian style of >programming if it prevents errors?? I've gotten too darn many times now by a It's always a matter of personal likes and dislikes. If you feel comfortable with it, then stick to it (I do it sometimes, not always, as I feel it's more important to try to hide stuff like private instance data than to blindly adhere to rigid coding standards, as long as you can read your code two months later) >Question: Is there a better way in classes to access/modify var's other than >get_var, put_var functions? Works great for me and I know whether I'm saving That's how OO is meant to be. Do it this way, even if the language doesn't enforce it. There's _really_ only a very small performance loss (approx. 0.01 msec per access). However take care - accessing _big_ data (like huge arrays, for example) using access functions may instantly measurable decrease performance, since variables are _copied_ unless you're using references. >a variable or accessing it. Sure, I'd like to be able to use a VB style >Set/Get property but who wouldn't?? Why don't you do it? class CSampleClass { var $m_a = 'value a'; var $m_b = 'value b'; function &Get($varname) { if (array_key_exists($varname, get_class_vars(get_class($this)))) return $this->$varname; // demo only echo '[', get_class($this), "::Get: class variable doesn't exist: $varname]"; return null; } function &Set($varname, $value) { if (array_key_exists($varname, get_class_vars(get_class($this)))) $this->$varname = $value; else echo '[', get_class($this), "::Set: class variable doesn't exist: $varname]"; } } $sc = new CSampleClass(); echo "m_a = ", $sc->Get('m_a'), ", m_b = ", $sc->Get('m_b'), ", other = ", $sc->Get('other'), "\n"; $sc->Set('m_a', 'new data for m_a'); $sc->Set('m_b', 'new data for m_b'); $sc->Set('other', 'new data for other'); echo "m_a = ", $sc->Get('m_a'), ", m_b = ", $sc->Get('m_b'), ", other = ", $sc->Get('other'), "\n"; -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php