Re: Naming convensions
| From: | Stoyan Stefanov | Date: | Thu, 04 Aug 2005 15:24:27 +0000 |
| Subject: | Re: Naming convensions | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-39214@lists.php.net to get a copy of this message | ||
Hi guys,
I looked at some of the most popular packages - 26 in total that have
100K+ downloads. It was a close race and the winner is ... :)
$some_var = 10
$someVar = 14
cannot tell = 2
It looks like the more recent packages tend towards using $someVars.
So I guess the manual can state something like:
"While using $some_vars used to acceptable, it's now discouraged in
favor of $someVars. Newly created packages MUST use $someVars in order
to be considered. This applies to all variables regardless of their
scope."
I think that last bit will ease the maintainability, consider this:
class Some_Thing {
var $_i_am_private;
var $iAmPublic;
function Some_Thing($and_I_canBe_ANYthing) {}
}
Some more about the 26 packages I looked at:
DB - $some_var
PHPUnit - $someVar
Net_Socket - $someVar
PEAR - $some_var
Mail - $some_var
XML_Parser - $someVar
Net_SMTP - $some_var
XML_RPC - Not consistent but the public vars are $some_var
Archive_Tar - $some_var
Console_Getopt - $some_var (no public vars here)
Log - not consistent, some pref to $someVar, couldn't find any public
vars though
Mail_Mime - $some_var (no public ones)
HTTP_Request - not consistent, no public
Date - none, $somevar instead, uses $someVar internally
HTML_QuickForm - $someVar
Auth - $someVar (one $advancedsecurity spotted though)
HTTP - $someVar (no public)
HTML_Common - $someVar (no public)
HTML_Template_IT - $someVars (a few $blocksomethings spotted)
Pager - not consistent, $_classVars and $in_method_vars, counted for
$someVars because of the arrayOfPublicOptions, spotted one
__such_method()
Net_URL - $someVars ($querystring spotted)
Net_UserAgent_Detect - $someVar (with $some_minorInconsistences)
SOAP - not consistent
Cache - $some_var
DB_DataObject - $some_var (didn't see any two word public ones though)
File - $someVar
Regards,
Stoyan