|
Posted by Jerry Stuckle on 09/04/07 11:07
Marijn wrote:
> On 4 sep, 10:02, Toby A Inkster <usenet200...@tobyinkster.co.uk>
> wrote:
>> Marijn wrote:
>>> private function __getDatabaseConnection(){
>>> if (!$this->__databaseConnection) {
>>> $this->__databaseConnection = new DatabaseFactory();
>>> };
>>> return($this->__databaseConnection);
>>> }
>>> }
>> I certainly prefer this.
>
> But because it's faster or..?
>
>>> By the way, another small convention question: Should you terminate
>>> control structures with a semicolon?
>> No. In fact, in this particular case, you don't even need the braces.
>> Using my own preferred coding style, it would be:
>
> I do prefer the braces. Really makes my code more readable
>
>
>> private function __getDatabaseConnection ()
>> {
>> if (!isset($this->__databaseConnection))
>> $this->__databaseConnection = new DatabaseFactory();
>>
>> return $this->__databaseConnection;
>> }
>>
>> By the way, you shouldn't name your functions with a double-underscore.
>> Functions that start with a double-underscore are reserved for future use
>> as "magic" functions (e.g. __construct, __call, __get, __autoload, etc).
>>
>
> I know it is for reserverd magic functions BUT this way i serarate
> public (no underscore) from (protected one underscore) from (private
> (two underscores)
>
> I really prefer a difference in my code for private and protected
> methods.
>
> Plus everybody with a bit of experience knows that ther is __call,
> __autoload, __desctruct ...etc.
>
But Toby is correct. Double underscores are reserved for PHP "magic"
functions.
Someone else looks at your code, and they will think these are supposed
to be PHP functions. And/or, sooner or later, you will run afoul of a
PHP function added when you upgrade PHP.
I'd really suggest you find another way to do it. But it's easy for me
- I have no public variables, and very few protected ones.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|