Re: Some PEAR remarks

From: Date: Wed, 17 Apr 2002 14:54:48 +0000
Subject: Re: Some PEAR remarks
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1196@lists.php.net to get a copy of this message
Maxim, 16:51:08 17. april 2002 (streda) Greets. > A question in advance: why are member variables in PEAR prefixed with a > '_'? Sure this is useful in languages like Java or C++ where it's hard to > see which variable is a local one, an argument or a member, but in PHP > this distinction is already clear: all member variables are prefixed with > '$this->' inside a method. And if you use proper encapsulation, member > variables are never accessed from anywhere else. (And very, very sadly, > this is not the case in the PEAR library!) My opinion: Private class properties are prefixed with '_' due to PHP which has no real private class members. If I want to make public property (I will never, but if yes), I don't prefix it. > Class DB is a class with static methods only, and the two most important > ones (factory and connect) either return an object of the requested type, > or an instance of class 'PEAR_Error'. Again, I think this is not a good > separation of 'normal' code and 'error' code. Also, whenever some code > calls one of these methods, it should always check whether the object > returned is the one they wanted, or something else. This raises a > question: how often is this done by your typical lazy programmer? And what > about production-state code? That kind of code doesn't contain any > programming errors, so then there's no need to check for them. You can make you own error handler via callback function and there recognize according to production state what to do with occured error. =Nepto= ____________________________________________________________________________ Ondrej 'Nepto' Jombik, http://www.nepto.sk/ nepto@atomicpile.sk

« previous php.pear.general (#1196) next »