> First, I don't think this belongs in the PHP Manual (It has nothing to
> do with PHP itself, and there are many resources about patterns out
> there).

Most of the resources about patterns I've looked at suck, I thought it would 
be good to have a place where the patterns are clearly explained, examples 
shown and PHP 5 based.

I'm not sure what you mean when you say it has nothing to do with PHP... The 
lack of good design is a problem I feel we should be addressing, as we've 
started to do with the Magic Quotes, SQL Injection, etc chapters.

I'm happy for it to be moved elsewhere, myself and curt (sorry to dob you in 
curt :P) thought this would be the best place.

> Second, if this goes in, the examples should be "done right". Right now
> they look like more like PHP4 code then like PHP5 code.
>
> For example, the singleton would look better like this:
>
> class Test {
>    static private $instance;
>
>    private function __construct()
>    {
>    }
>
>    static public function singleton()
>    {
>        if (!isset(self::$instance)) {
>            self::$instance = new Test;
>        }
>        return self::$instance;
>    }
>
>    public function bark()
>    {
>        print "Woof!\n";
>    }
> }
>
> // This would fail, because the constructor is private:
> // $test = new Test;
> // But this works:
> $test = Test::singleton();
> $test->bark();
>

I agree the examples should be done right, I'll update them now. 

Reply via email to