mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-04 22:17: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
|
||||
*
|
||||
* Examples:
|
||||
* - 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.))
|
||||
* - Zend Framework: Zend_Form::createElement() creates form elements, but you could also call new T
|
||||
* TextElement() instead
|
||||
* - 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.))
|
||||
* - Zend Framework: Zend_Form::createElement() creates form elements, but you could also call
|
||||
* new TextElement() instead
|
||||
*
|
||||
*/
|
||||
abstract class AbstractFactory
|
||||
|
@@ -12,7 +12,7 @@ namespace DesignPatterns;
|
||||
* Examples:
|
||||
* - 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
|
||||
{
|
||||
|
@@ -6,11 +6,13 @@ namespace DesignPatterns;
|
||||
* composite pattern
|
||||
*
|
||||
* 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:
|
||||
* - 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
|
||||
|
@@ -10,6 +10,8 @@ namespace DesignPatterns;
|
||||
*
|
||||
* Examples:
|
||||
* - 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
|
||||
|
@@ -46,6 +46,7 @@ class Multiton
|
||||
|
||||
/**
|
||||
* gets the instance with the given name, e.g. Multiton::INSTANCE_1
|
||||
* uses lazy initialization
|
||||
*
|
||||
* @param string $instanceName
|
||||
* @return Multiton
|
||||
|
@@ -6,7 +6,7 @@ namespace DesignPatterns;
|
||||
* Prototype pattern
|
||||
*
|
||||
* 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:
|
||||
* - 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
|
||||
*
|
||||
* 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:
|
||||
* - 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 ...)
|
||||
*
|
||||
*/
|
||||
|
Reference in New Issue
Block a user