Re: PEAR Coding Standards question

From: Date: Tue, 19 Aug 2008 22:17:42 +0000
Subject: Re: PEAR Coding Standards question
References: 1 2 3 4 5 6 7  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-50575@lists.php.net to get a copy of this message
On 19.08.2008, at 23:51, Joe Stump wrote:
1.) Protected variables can be made public via child classes, leaving us with a public variable that has a prefixed underscore.
Right. Something that seems to rarely happen in practice. I also never remember it being an issue back in the PHP4 days. So in the end I can only reply to this that since it seems to happen so seldom in practice (I cannot think of an example in PEAR, though there probably are some), it does not offset the advantages I see.
2.) The underscore does *nothing* to indicate if it's protected or private.
Yes it does if we say it does and use it accordingly.
3.) It smacks of Hungarian notation. Why not just prepend everything with public_, private_ and protected_?
Because that obfuscates code, where as the underscore only adds a single character that is easy to spot.
4.) If I ever decide to loosen access to a variable or method I actually have to break BC to loosen those restrictions as it stands. I can't simply make "private $foo" "public $foo" because it *has* to be "private $_foo", but "public $_foo" is a CS error.
I guess is your 1) point again in a slightly different package. I have not clue what BC has to do with this. In the rare case (feel free to proof me wrong on my assertion .. or just claim otherwise, since I do not proof my assertion either) where indeed you want to loosen the accessibility, I would vote for allowing public properties/methods to start with an underscore. Anyways, not really important and CS is mostly taste and thats hard to "discuss". Which is why traditionally this list has tried to quickly kill such discussions and I think since we have a PEAR Group, any updates where put in their hands. regards, Lukas Kahwe Smith mls@pooteeweet.org

« previous php.pear.dev (#50575) next »