mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-05 06:27:25 +02:00
some more comments, typos etc.
This commit is contained in:
@@ -10,10 +10,10 @@ namespace DesignPatterns;
|
|||||||
* usually the created classes all implement the same interface
|
* usually the created classes all implement the same interface
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* - A Factory to create media in a CMS: classes would be text, audio, video, picture
|
* - A factory to create media in a CMS: classes would be text, audio, video, picture
|
||||||
* - SQL Factory (types are all strings with SQL, but they vary in detail (tables, fields, etc.))
|
* - SQL factory (types are all strings with SQL, but they vary in detail (tables, fields, etc.))
|
||||||
* - Zend Framework: Zend_Form::createElement() creates form elements, but you could also call new T
|
* - Zend Framework: Zend_Form::createElement() creates form elements, but you could also call
|
||||||
* TextElement() instead
|
* new TextElement() instead
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract class AbstractFactory
|
abstract class AbstractFactory
|
||||||
|
@@ -12,7 +12,7 @@ namespace DesignPatterns;
|
|||||||
* Examples:
|
* Examples:
|
||||||
* - different databases have the same interface to communicate although the underlying systems act differently
|
* - different databases have the same interface to communicate although the underlying systems act differently
|
||||||
*
|
*
|
||||||
* this is a VERY basic example which won't work at all
|
* this is a VERY basic example which won't work at all!
|
||||||
*/
|
*/
|
||||||
interface DatabaseAdapter
|
interface DatabaseAdapter
|
||||||
{
|
{
|
||||||
|
@@ -6,11 +6,13 @@ namespace DesignPatterns;
|
|||||||
* composite pattern
|
* composite pattern
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
* to treat a group of objects the same way as a single instance of the object
|
* to treat a group of objects the same way as a single instance of the object, it establishes 1-to-n relationships
|
||||||
|
* between objects
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* - a form class instance handles all its form elements like a single instance of the form, when render() is called, it
|
* - a form class instance handles all its form elements like a single instance of the form, when render() is called, it
|
||||||
* subsequently runs trough all its child elements and calls render() on them
|
* subsequently runs trough all its child elements and calls render() on them
|
||||||
|
* - a class to process files would process it by running process on all row objects in the file
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Form
|
class Form
|
||||||
|
@@ -10,6 +10,8 @@ namespace DesignPatterns;
|
|||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* - Database Abstraction Layers
|
* - Database Abstraction Layers
|
||||||
|
* - Doctrine2: EntityManager is the facade that one sees from the outside, but in there is much more going on, Unit of
|
||||||
|
* Work, etc.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Facade
|
class Facade
|
||||||
|
@@ -46,6 +46,7 @@ class Multiton
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the instance with the given name, e.g. Multiton::INSTANCE_1
|
* gets the instance with the given name, e.g. Multiton::INSTANCE_1
|
||||||
|
* uses lazy initialization
|
||||||
*
|
*
|
||||||
* @param string $instanceName
|
* @param string $instanceName
|
||||||
* @return Multiton
|
* @return Multiton
|
||||||
|
@@ -6,7 +6,7 @@ namespace DesignPatterns;
|
|||||||
* Prototype pattern
|
* Prototype pattern
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
* to avoid the the cost of creating objects the standard way (new Foo()) and instead create a prototype and clone it
|
* to avoid the cost of creating objects the standard way (new Foo()) and instead create a prototype and clone it
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* - Large amounts of data (e.g. create 1,000,000 rows in a database at once via a ORM)
|
* - Large amounts of data (e.g. create 1,000,000 rows in a database at once via a ORM)
|
||||||
|
@@ -6,11 +6,11 @@ namespace DesignPatterns;
|
|||||||
* Singleton pattern
|
* Singleton pattern
|
||||||
*
|
*
|
||||||
* Purpose:
|
* Purpose:
|
||||||
* - to have only one instance of this object in the application, that handles all calls
|
* to have only one instance of this object in the application, that will handle all calls
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* - DB Connector
|
* - DB Connector
|
||||||
* - Logger (May also be a Multiton if there are many Logfiles for several purposes)
|
* - Logger (may also be a Multiton if there are many log files for several purposes)
|
||||||
* - Lock file for the application (there is only one in the filesystem ...)
|
* - Lock file for the application (there is only one in the filesystem ...)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user