Re: Code Critique Please :)
| From: | Oscar Gosdinski | Date: | Thu, 22 Nov 2007 17:46:22 +0000 |
| Subject: | Re: Code Critique Please :) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264968@lists.php.net to get a copy of this message | ||
On Nov 21, 2007 2:05 PM, Simeon F. Willbanks <simeon@simeons.net> wrote:
> 3. Object Oriented principles
I see that you tried to implement Singleton pattern in the DB class,
but you have a mistake. $dbConnection attribute is not a static
member, so every time you call the constructor $dbConnection won't be
initialized, so your code will always initialize this attribute.
There is something that i always wonder about Singleton pattern in
PHP, do you really have a benefit using this pattern in PHP? The idea
behind this pattern is that only one instance of the class is created,
it works great in Java because all requests are processed inside a JVM
and this instance created will really be the only one defined. Because
in PHP every request has its own environment, you will have several
instances of this class per request processed.
> 4. Strategy Design Pattern
> - Interface used for column attribute parsing
I've checked the code in MySQLToXML.phps and i see a lot of
ParseDatabaseColumnAttributeXXX classes that implements
ParseDatabaseColumnAttribute interface. I think that those classes
should be methods of a DatabaseColumnAttributeParser instead of
defining so many classes. Also the names of those classes suggest me
that they are methods not objects.
--
Saludos
Oscar