View Single Post
Old 10-16-2008, 11:57 AM   #4 (permalink)
sketchMedia
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I do have to agree, although its certainly not the worst code block i have ever seen, it certainly could do with a bit of a tidy up.

Why if you are using a class that has PHP5 style syntax have you used 'var' instead of the visibility modifiers, if you want the class to be PHP4 compliant, you will need to remove your construct and replace it with the C++ style constructor (a method with the same name as the class), if not then use either 'public', 'private' or 'protected' instead of var (it used to call a E_STRICT warning, but i cant seem to replicate it).

Dont call non-static methods as static:
PHP Code:
self::co(); 
you call them using $this (unless declared as static, which isn't the case here):
PHP Code:
$this->co(); 
You need to also name your methods so that they are descriptive, I.E.
PHP Code:
public function connect() {}
public function 
disconnect() {}
public function 
execQuery() {} 
as opposed to:
PHP Code:
public function co() {}
public function 
cl() {}
public function 
q() {} 
Looking at the first example, i am immediately able to see what the method does because the name describes it well, therefore i don't need to actually read the code to find out what it does.

Apart from that its all personal preference. I personally would have the code block delimiters {} on a new line and I wouldn't use the bash comment style.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote