note 54550 added to language.oop5.patterns
| From: | php at mijav dot dk | Date: | Thu, 07 Jul 2005 16:46:15 +0000 |
| Subject: | note 54550 added to language.oop5.patterns | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91601@lists.php.net to get a copy of this message | ||
Please use design patterns as they were intended:
Design patterns are designs that are known to solve common problems, such as having only 1 instance
of a class. Design patterns are are not code libraries.
Most design patterns, if not all, have alternate implementations but common to them all is that the
recommended implementation solves the problem.
Singleton should not be made as a class and then extended. Nor shuld __autoload be used.
Autoloading is very PHP-specific (and there might be nothing wrong with that, but design patterns
are general patterns that are abstracted from the implementing language).
Making a class that you extend is very ugly. What if you have to extend that class too? You will
have to make a dummy that extends your singleton class, just so you can extend the class you want.
This is a very "ugly" solution that completely overrules the idea of well known design
patters: A thought-though idea that works the way intended.
The manual shows a PHP implementation of the standard Singleton-pattern without "nifty"
modifications.
To finish off this lesson on design patterns, I would like to ackknowledge that there is nothing
wrong in tweaking patterns to suit your needs.
But remember: "If it isn't broken - don't fix it".
----
Manual Page -- http://www.php.net/manual/en/language.oop5.patterns.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54550
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54550&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54550&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54550&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54550&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54550&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54550&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54550&report=yes
Search -- http://master.php.net/manage/user-notes.php