Reply to Re: Code readability vs. execution time

Your name:

Reply:


Posted by Toby A Inkster on 09/04/07 08:02

Marijn wrote:

> private function __getDatabaseConnection(){
> if (!$this->__databaseConnection) {
> $this->__databaseConnection = new DatabaseFactory();
> };
> return($this->__databaseConnection);
> }
> }

I certainly prefer this.

> 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:

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).

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 75 days, 11:36.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация