Merge branch 'pr/107' into master
@@ -10,3 +10,7 @@ To build a chain of objects to handle a call in sequential order. If one object
|
||||
* a Spam filter
|
||||
* Caching: first object is an instance of e.g. a Memcached Interface, if that "misses" it delegates the call to the database interface
|
||||
* Yii Framework: CFilterChain is a chain of controller action filters. the executing point is passed from one filter to the next along the chain, and only if all filters say "yes", the action can be invoked at last.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
||||
|
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\ChainOfResponsibilities\Handler</OriginalElement>
|
||||
<nodes>
|
||||
<node x="54.5" y="0.0">\DesignPatterns\Behavioral\ChainOfResponsibilities\Handler</node>
|
||||
<node x="0.0" y="158.0">\DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage</node>
|
||||
<node x="154.0" y="158.0">\DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage</node>
|
||||
<node x="304.0" y="45.0">\DesignPatterns\Behavioral\ChainOfResponsibilities\Request</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage" target="\DesignPatterns\Behavioral\ChainOfResponsibilities\Handler">
|
||||
<point x="0.0" y="-44.5" />
|
||||
<point x="67.0" y="133.0" />
|
||||
<point x="99.25" y="133.0" />
|
||||
<point x="-44.75" y="54.0" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage" target="\DesignPatterns\Behavioral\ChainOfResponsibilities\Handler">
|
||||
<point x="0.0" y="-44.5" />
|
||||
<point x="221.0" y="133.0" />
|
||||
<point x="188.75" y="133.0" />
|
||||
<point x="44.75" y="54.0" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="188.0" y="123.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/ChainOfResponsibilities/uml/uml.png
Normal file
After Width: | Height: | Size: 10 KiB |
363
Behavioral/ChainOfResponsibilities/uml/uml.svg
Normal file
After Width: | Height: | Size: 48 KiB |
@@ -15,3 +15,7 @@ Command can also be aggregated to combine more complex commands with minimum cop
|
||||
* A text editor : all events are Command which can be undone, stacked and saved.
|
||||
* Symfony2: SF2 Commands that can be run from the CLI are built with just the Command pattern in mind
|
||||
* big CLI tools use subcommands to distribute various tasks and pack them in "modules", each of these can be implemented with the Command pattern (e.g. vagrant)
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
28
Behavioral/Command/uml/Command.uml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Command\HelloCommand</OriginalElement>
|
||||
<nodes>
|
||||
<node x="185.0" y="15.0">\DesignPatterns\Behavioral\Command\Invoker</node>
|
||||
<node x="0.0" y="97.0">\DesignPatterns\Behavioral\Command\HelloCommand</node>
|
||||
<node x="189.0" y="139.0">\DesignPatterns\Behavioral\Command\Receiver</node>
|
||||
<node x="10.0" y="0.0">\DesignPatterns\Behavioral\Command\CommandInterface</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Command\HelloCommand" target="\DesignPatterns\Behavioral\Command\CommandInterface">
|
||||
<point x="0.0" y="-44.5" />
|
||||
<point x="0.0" y="23.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="171.0" y="93.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Command/uml/uml.png
Normal file
After Width: | Height: | Size: 10 KiB |
366
Behavioral/Command/uml/uml.svg
Normal file
After Width: | Height: | Size: 44 KiB |
@@ -11,3 +11,7 @@ To make an object iterable and to make it appear like a collection of objects.
|
||||
## Note
|
||||
|
||||
Standard PHP Library (SPL) defines an interface Iterator which is best suited for this! Often you would want to implement the Countable interface too, to allow `count($object)` on your iterable object
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
28
Behavioral/Iterator/uml/Iterator.uml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Iterator\Book</OriginalElement>
|
||||
<nodes>
|
||||
<node x="30.0" y="239.0">\DesignPatterns\Behavioral\Iterator\BookListReverseIterator</node>
|
||||
<node x="315.380829015544" y="226.96891191709844">\DesignPatterns\Behavioral\Iterator\BookList</node>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\Behavioral\Iterator\BookListIterator</node>
|
||||
<node x="296.0" y="0.0">\DesignPatterns\Behavioral\Iterator\Book</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Iterator\BookListReverseIterator" target="\DesignPatterns\Behavioral\Iterator\BookListIterator">
|
||||
<point x="0.0" y="-64.5" />
|
||||
<point x="0.0" y="94.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="250.0" y="184.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Iterator/uml/uml.png
Normal file
After Width: | Height: | Size: 15 KiB |
638
Behavioral/Iterator/uml/uml.svg
Normal file
After Width: | Height: | Size: 80 KiB |
@@ -9,3 +9,7 @@ like a controller (but not in the sense of the MVC).
|
||||
All components (called Colleague) are only coupled to the MediatorInterface and
|
||||
it is a good thing because in OOP, one good friend is better than many. This
|
||||
is the key-feature of this pattern.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
46
Behavioral/Mediator/uml/Mediator.uml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Mediator\Colleague</OriginalElement>
|
||||
<nodes>
|
||||
<node x="196.3419689119171" y="221.44559585492226">\DesignPatterns\Behavioral\Mediator\Subsystem\Database</node>
|
||||
<node x="-347.65803108808296" y="7.461139896373059">\DesignPatterns\Behavioral\Mediator\MediatorInterface</node>
|
||||
<node x="55.34196891191709" y="211.44559585492226">\DesignPatterns\Behavioral\Mediator\Subsystem\Client</node>
|
||||
<node x="-353.65803108808296" y="144.46113989637306">\DesignPatterns\Behavioral\Mediator\Mediator</node>
|
||||
<node x="-65.65803108808291" y="221.44559585492226">\DesignPatterns\Behavioral\Mediator\Subsystem\Server</node>
|
||||
<node x="38.84196891191709" y="72.44559585492226">\DesignPatterns\Behavioral\Mediator\Colleague</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Mediator\Subsystem\Server" target="\DesignPatterns\Behavioral\Mediator\Colleague">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="-15.158031088082907" y="186.44559585492226" />
|
||||
<point x="64.50863557858375" y="186.44559585492226" />
|
||||
<point x="-51.333333333333336" y="44.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Mediator\Mediator" target="\DesignPatterns\Behavioral\Mediator\MediatorInterface">
|
||||
<point x="0.0" y="-84.0" />
|
||||
<point x="0.0" y="43.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Mediator\Subsystem\Client" target="\DesignPatterns\Behavioral\Mediator\Colleague">
|
||||
<point x="0.0" y="-33.5" />
|
||||
<point x="0.0" y="44.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Mediator\Subsystem\Database" target="\DesignPatterns\Behavioral\Mediator\Colleague">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="247.8419689119171" y="186.44559585492226" />
|
||||
<point x="167.17530224525044" y="186.44559585492226" />
|
||||
<point x="51.33333333333334" y="44.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="-27.0" y="160.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Mediator/uml/uml.png
Normal file
After Width: | Height: | Size: 20 KiB |
651
Behavioral/Mediator/uml/uml.svg
Normal file
After Width: | Height: | Size: 77 KiB |
@@ -16,3 +16,7 @@ When using this pattern, care should be taken if the originator may change other
|
||||
|
||||
* The seed of a pseudorandom number generator
|
||||
* The state in a finite state machine
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
22
Behavioral/Memento/uml/Momento.uml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Memento\Caretaker</OriginalElement>
|
||||
<nodes>
|
||||
<node x="182.0" y="153.0">\DesignPatterns\Behavioral\Memento\Caretaker</node>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\Behavioral\Memento\Originator</node>
|
||||
<node x="0.0" y="153.0">\DesignPatterns\Behavioral\Memento\Memento</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges />
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="131.0" y="121.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Memento/uml/uml.png
Normal file
After Width: | Height: | Size: 8.2 KiB |
310
Behavioral/Memento/uml/uml.svg
Normal file
After Width: | Height: | Size: 40 KiB |
@@ -18,3 +18,7 @@ a statement like `if (!is_null($obj)) { $obj->callSomething(); }` anymore.
|
||||
* Symfony2: null output in Symfony/Console
|
||||
* null handler in a Chain of Responsibilities pattern
|
||||
* null command in a Command pattern
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
36
Behavioral/NullObject/uml/NullObject.uml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\NullObject\Service</OriginalElement>
|
||||
<nodes>
|
||||
<node x="111.0" y="97.0">\DesignPatterns\Behavioral\NullObject\NullLogger</node>
|
||||
<node x="0.0" y="97.0">\DesignPatterns\Behavioral\NullObject\PrintLogger</node>
|
||||
<node x="46.0" y="0.0">\DesignPatterns\Behavioral\NullObject\LoggerInterface</node>
|
||||
<node x="0.0" y="189.0">\DesignPatterns\Behavioral\NullObject\Service</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\NullObject\NullLogger" target="\DesignPatterns\Behavioral\NullObject\LoggerInterface">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="156.5" y="72.0" />
|
||||
<point x="128.5" y="72.0" />
|
||||
<point x="27.5" y="23.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\NullObject\PrintLogger" target="\DesignPatterns\Behavioral\NullObject\LoggerInterface">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="45.5" y="72.0" />
|
||||
<point x="73.5" y="72.0" />
|
||||
<point x="-27.5" y="23.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="101.0" y="139.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/NullObject/uml/uml.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
304
Behavioral/NullObject/uml/uml.svg
Normal file
After Width: | Height: | Size: 39 KiB |
@@ -11,4 +11,8 @@ To implement a publish/subscribe behaviour to an object, whenever a "Subject" ob
|
||||
|
||||
## Note
|
||||
|
||||
PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject.
|
||||
PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
27
Behavioral/Observer/uml/Observer.uml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Observer\User</OriginalElement>
|
||||
<nodes>
|
||||
<node x="239.0" y="0.0">\DesignPatterns\Behavioral\Observer\UserObserver</node>
|
||||
<node x="0.0" y="137.0">\DesignPatterns\Behavioral\Observer\User</node>
|
||||
<node x="8.0" y="0.0">\SplSubject</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Observer\User" target="\SplSubject">
|
||||
<point x="0.0" y="-74.0" />
|
||||
<point x="0.0" y="43.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="186.0" y="142.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Observer/uml/uml.png
Normal file
After Width: | Height: | Size: 9.7 KiB |
310
Behavioral/Observer/uml/uml.svg
Normal file
After Width: | Height: | Size: 42 KiB |
@@ -5,3 +5,6 @@
|
||||
Builds a clear specification of business rules, where objects can be checked against. The composite specification class has
|
||||
one method called `isSatisfiedBy` that returns either true or false depending on whether the given object satisfies the specification.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
55
Behavioral/Specification/uml/Specification.uml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Specification\AbstractSpecification</OriginalElement>
|
||||
<nodes>
|
||||
<node x="168.0" y="314.0">\DesignPatterns\Behavioral\Specification\PriceSpecification</node>
|
||||
<node x="551.0" y="333.5">\DesignPatterns\Behavioral\Specification\Not</node>
|
||||
<node x="259.25" y="0.0">\DesignPatterns\Behavioral\Specification\SpecificationInterface</node>
|
||||
<node x="383.0" y="323.5">\DesignPatterns\Behavioral\Specification\Plus</node>
|
||||
<node x="259.25" y="157.0">\DesignPatterns\Behavioral\Specification\AbstractSpecification</node>
|
||||
<node x="0.0" y="323.5">\DesignPatterns\Behavioral\Specification\Either</node>
|
||||
<node x="0.0" y="487.0">\DesignPatterns\Behavioral\Specification\Item</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Specification\Plus" target="\DesignPatterns\Behavioral\Specification\AbstractSpecification">
|
||||
<point x="0.0" y="-54.5" />
|
||||
<point x="457.0" y="294.0" />
|
||||
<point x="386.75" y="294.0" />
|
||||
<point x="25.5" y="53.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Specification\AbstractSpecification" target="\DesignPatterns\Behavioral\Specification\SpecificationInterface">
|
||||
<point x="0.0" y="-53.5" />
|
||||
<point x="0.0" y="53.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Specification\PriceSpecification" target="\DesignPatterns\Behavioral\Specification\AbstractSpecification">
|
||||
<point x="0.0" y="-64.0" />
|
||||
<point x="265.5" y="294.0" />
|
||||
<point x="335.75" y="294.0" />
|
||||
<point x="-25.5" y="53.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Specification\Not" target="\DesignPatterns\Behavioral\Specification\AbstractSpecification">
|
||||
<point x="0.0" y="-44.5" />
|
||||
<point x="618.0" y="284.0" />
|
||||
<point x="437.75" y="284.0" />
|
||||
<point x="76.5" y="53.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Specification\Either" target="\DesignPatterns\Behavioral\Specification\AbstractSpecification">
|
||||
<point x="0.0" y="-54.5" />
|
||||
<point x="74.0" y="284.0" />
|
||||
<point x="284.75" y="284.0" />
|
||||
<point x="-76.5" y="53.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="0.6476510067114094" x="342.5" y="288.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Specification/uml/uml.png
Normal file
After Width: | Height: | Size: 25 KiB |
761
Behavioral/Specification/uml/uml.svg
Normal file
After Width: | Height: | Size: 97 KiB |
@@ -3,3 +3,7 @@
|
||||
## Purpose
|
||||
|
||||
Encapsulate varying behavior for the same routine based on an object's state. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
37
Behavioral/State/uml/State.uml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\State\OrderInterface</OriginalElement>
|
||||
<nodes>
|
||||
<node x="0.0" y="271.0">\DesignPatterns\Behavioral\State\OrderFactory</node>
|
||||
<node x="178.0" y="117.0">\DesignPatterns\Behavioral\State\CreateOrder</node>
|
||||
<node x="202.0" y="271.0">\DesignPatterns\Behavioral\State\OrderController</node>
|
||||
<node x="102.5" y="0.0">\DesignPatterns\Behavioral\State\OrderInterface</node>
|
||||
<node x="0.0" y="117.0">\DesignPatterns\Behavioral\State\ShippingOrder</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\State\ShippingOrder" target="\DesignPatterns\Behavioral\State\OrderInterface">
|
||||
<point x="0.0" y="-54.5" />
|
||||
<point x="79.0" y="92.0" />
|
||||
<point x="135.25" y="92.0" />
|
||||
<point x="-32.75" y="33.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\State\CreateOrder" target="\DesignPatterns\Behavioral\State\OrderInterface">
|
||||
<point x="0.0" y="-54.5" />
|
||||
<point x="257.0" y="92.0" />
|
||||
<point x="200.75" y="92.0" />
|
||||
<point x="32.75" y="33.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="171.5" y="169.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/State/uml/uml.png
Normal file
After Width: | Height: | Size: 12 KiB |
460
Behavioral/State/uml/uml.svg
Normal file
After Width: | Height: | Size: 59 KiB |
@@ -14,3 +14,7 @@ To separate strategies and to enable fast switching between them. Also this patt
|
||||
|
||||
* sorting a list of objects, one strategy by date, the other by id
|
||||
* simplify unit testing: e.g. switching between file and in-memory storage
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
36
Behavioral/Strategy/uml/Strategy.uml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Strategy\ComparatorInterface</OriginalElement>
|
||||
<nodes>
|
||||
<node x="324.0" y="6.0">\DesignPatterns\Behavioral\Strategy\ObjectCollection</node>
|
||||
<node x="144.0" y="97.0">\DesignPatterns\Behavioral\Strategy\DateComparator</node>
|
||||
<node x="67.0" y="0.0">\DesignPatterns\Behavioral\Strategy\ComparatorInterface</node>
|
||||
<node x="0.0" y="97.0">\DesignPatterns\Behavioral\Strategy\IdComparator</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Strategy\IdComparator" target="\DesignPatterns\Behavioral\Strategy\ComparatorInterface">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="62.0" y="72.0" />
|
||||
<point x="100.5" y="72.0" />
|
||||
<point x="-33.5" y="23.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Strategy\DateComparator" target="\DesignPatterns\Behavioral\Strategy\ComparatorInterface">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="206.0" y="72.0" />
|
||||
<point x="167.5" y="72.0" />
|
||||
<point x="33.5" y="23.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="259.5" y="72.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Strategy/uml/uml.png
Normal file
After Width: | Height: | Size: 11 KiB |
314
Behavioral/Strategy/uml/uml.svg
Normal file
After Width: | Height: | Size: 42 KiB |
@@ -12,3 +12,7 @@ How? With abstraction of course.
|
||||
In other words, this is a skeleton of algorithm, well-suited for framework libraries. The user has just to implement one method and the superclass do the job.
|
||||
|
||||
It is an easy way to decouple concrete classes and reduce copy-paste, that's why you'll find it everywhere.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
35
Behavioral/TemplateMethod/uml/TemplateMethod.uml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\TemplateMethod\BeachJourney</OriginalElement>
|
||||
<nodes>
|
||||
<node x="152.0" y="177.0">\DesignPatterns\Behavioral\TemplateMethod\CityJourney</node>
|
||||
<node x="47.0" y="0.0">\DesignPatterns\Behavioral\TemplateMethod\Journey</node>
|
||||
<node x="0.0" y="177.0">\DesignPatterns\Behavioral\TemplateMethod\BeachJourney</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\TemplateMethod\CityJourney" target="\DesignPatterns\Behavioral\TemplateMethod\Journey">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="218.0" y="152.0" />
|
||||
<point x="189.5" y="152.0" />
|
||||
<point x="47.5" y="63.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\TemplateMethod\BeachJourney" target="\DesignPatterns\Behavioral\TemplateMethod\Journey">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="66.0" y="152.0" />
|
||||
<point x="94.5" y="152.0" />
|
||||
<point x="-47.5" y="63.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="142.0" y="112.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/TemplateMethod/uml/uml.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
256
Behavioral/TemplateMethod/uml/uml.svg
Normal file
After Width: | Height: | Size: 35 KiB |
@@ -6,3 +6,7 @@ The Visitor Pattern lets you outsource operations on objects to other objects. T
|
||||
But classes have to define a contract to allow visitors (the `Role::accept` method in the example).
|
||||
|
||||
The contract is an abstract class but you can have also a clean interface. In that case, each Visitor has to choose itself which method to invoke on the visitor.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
41
Behavioral/Visitor/uml/Visitor.uml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Behavioral\Visitor\Group</OriginalElement>
|
||||
<nodes>
|
||||
<node x="-159.5" y="-99.0">\DesignPatterns\Behavioral\Visitor\Role</node>
|
||||
<node x="87.15544041450778" y="20.129533678756502">\DesignPatterns\Behavioral\Visitor\RolePrintVisitor</node>
|
||||
<node x="-87.0" y="-2.0">\DesignPatterns\Behavioral\Visitor\Group</node>
|
||||
<node x="90.65544041450778" y="-96.8704663212435">\DesignPatterns\Behavioral\Visitor\RoleVisitorInterface</node>
|
||||
<node x="-245.0" y="-2.0">\DesignPatterns\Behavioral\Visitor\User</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Behavioral\Visitor\RolePrintVisitor" target="\DesignPatterns\Behavioral\Visitor\RoleVisitorInterface">
|
||||
<point x="0.0" y="-33.5" />
|
||||
<point x="0.0" y="33.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Visitor\User" target="\DesignPatterns\Behavioral\Visitor\Role">
|
||||
<point x="0.0" y="-44.5" />
|
||||
<point x="-176.0" y="-27.0" />
|
||||
<point x="-128.25" y="-27.0" />
|
||||
<point x="-31.25" y="23.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Behavioral\Visitor\Group" target="\DesignPatterns\Behavioral\Visitor\Role">
|
||||
<point x="0.0" y="-44.5" />
|
||||
<point x="-18.0" y="-27.0" />
|
||||
<point x="-65.75" y="-27.0" />
|
||||
<point x="31.25" y="23.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="-3.5" y="-5.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Behavioral/Visitor/uml/uml.png
Normal file
After Width: | Height: | Size: 11 KiB |
441
Behavioral/Visitor/uml/uml.svg
Normal file
After Width: | Height: | Size: 55 KiB |
@@ -4,3 +4,7 @@
|
||||
|
||||
To create series of related or dependent objects without specifying their concrete classes.
|
||||
Usually the created classes all implement the same interface. The client of the abstract factory does not care about how these objects are created, he just knows how they go together.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
38
Creational/AbstractFactory/uml/AbstractFactory.uml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\AbstractFactory\AbstractFactory</OriginalElement>
|
||||
<nodes>
|
||||
<node x="281.0" y="228.0">\DesignPatterns\Creational\AbstractFactory\Html\Text</node>
|
||||
<node x="150.0" y="229.0">\DesignPatterns\Creational\AbstractFactory\Html\Picture</node>
|
||||
<node x="223.0" y="117.0">\DesignPatterns\Creational\AbstractFactory\HtmlFactory</node>
|
||||
<node x="0.0" y="117.0">\DesignPatterns\Creational\AbstractFactory\JsonFactory</node>
|
||||
<node x="126.0" y="0.0">\DesignPatterns\Creational\AbstractFactory\AbstractFactory</node>
|
||||
<node x="0.0" y="229.0">\DesignPatterns\Creational\AbstractFactory\MediaInterface</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Creational\AbstractFactory\HtmlFactory" target="\DesignPatterns\Creational\AbstractFactory\AbstractFactory">
|
||||
<point x="0.0" y="-33.5" />
|
||||
<point x="324.5" y="92.0" />
|
||||
<point x="256.5" y="92.0" />
|
||||
<point x="43.5" y="33.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\AbstractFactory\JsonFactory" target="\DesignPatterns\Creational\AbstractFactory\AbstractFactory">
|
||||
<point x="0.0" y="-33.5" />
|
||||
<point x="101.5" y="92.0" />
|
||||
<point x="169.5" y="92.0" />
|
||||
<point x="-43.5" y="33.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="213.0" y="138.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/AbstractFactory/uml/uml.png
Normal file
After Width: | Height: | Size: 12 KiB |
379
Creational/AbstractFactory/uml/uml.svg
Normal file
After Width: | Height: | Size: 50 KiB |
@@ -13,3 +13,7 @@ Note: Builders have often a fluent interface, see the mock builder of PHPUnit fo
|
||||
## Examples
|
||||
|
||||
* PHPUnit: Mock Builder
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
54
Creational/Builder/uml/Builder.uml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\Builder\BikeBuilder</OriginalElement>
|
||||
<nodes>
|
||||
<node x="211.45854922279796" y="202.76683937823833">\DesignPatterns\Creational\Builder\Parts\Door</node>
|
||||
<node x="210.05958549222794" y="108.9585492227979">\DesignPatterns\Creational\Builder\Parts\Engine</node>
|
||||
<node x="-194.71502590673578" y="194.2979274611399">\DesignPatterns\Creational\Builder\CarBuilder</node>
|
||||
<node x="210.12694300518137" y="155.98963730569943">\DesignPatterns\Creational\Builder\Parts\Wheel</node>
|
||||
<node x="111.45854922279796" y="157.76683937823833">\DesignPatterns\Creational\Builder\Parts\Bike</node>
|
||||
<node x="42.458549222797956" y="157.76683937823833">\DesignPatterns\Creational\Builder\Parts\Car</node>
|
||||
<node x="-405.7150259067358" y="194.2979274611399">\DesignPatterns\Creational\Builder\BikeBuilder</node>
|
||||
<node x="-309.7150259067358" y="17.2979274611399">\DesignPatterns\Creational\Builder\BuilderInterface</node>
|
||||
<node x="44.958549222797956" y="39.76683937823833">\DesignPatterns\Creational\Builder\Parts\Vehicle</node>
|
||||
<node x="207.45854922279796" y="39.76683937823833">\DesignPatterns\Creational\Builder\Director</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Creational\Builder\BikeBuilder" target="\DesignPatterns\Creational\Builder\BuilderInterface">
|
||||
<point x="0.0" y="-74.0" />
|
||||
<point x="-310.2150259067358" y="169.2979274611399" />
|
||||
<point x="-257.7150259067358" y="169.2979274611399" />
|
||||
<point x="-52.0" y="63.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\Builder\CarBuilder" target="\DesignPatterns\Creational\Builder\BuilderInterface">
|
||||
<point x="0.0" y="-74.0" />
|
||||
<point x="-101.21502590673578" y="169.2979274611399" />
|
||||
<point x="-153.71502590673578" y="169.2979274611399" />
|
||||
<point x="52.0" y="63.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\Builder\Parts\Car" target="\DesignPatterns\Creational\Builder\Parts\Vehicle">
|
||||
<point x="0.0" y="-13.5" />
|
||||
<point x="66.95854922279796" y="132.76683937823833" />
|
||||
<point x="73.45854922279796" y="132.76683937823833" />
|
||||
<point x="-28.5" y="34.0" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\Builder\Parts\Bike" target="\DesignPatterns\Creational\Builder\Parts\Vehicle">
|
||||
<point x="0.0" y="-13.5" />
|
||||
<point x="136.95854922279796" y="132.76683937823833" />
|
||||
<point x="130.45854922279796" y="132.76683937823833" />
|
||||
<point x="28.5" y="34.0" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="-40.0" y="180.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/Builder/uml/uml.png
Normal file
After Width: | Height: | Size: 23 KiB |
832
Creational/Builder/uml/uml.svg
Normal file
After Width: | Height: | Size: 97 KiB |
@@ -9,3 +9,7 @@ For simple case, this abstract class could be just an interface
|
||||
This pattern is a "real" Design Pattern because it achieves the "Dependency Inversion Principle" a.k.a the "D" in S.O.L.I.D principles.
|
||||
|
||||
It means the FactoryMethod class depends on abstractions, not concrete classes. This is the real trick compared to SimpleFactory or StaticFactory.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
55
Creational/FactoryMethod/uml/FactoryMethod.uml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\FactoryMethod\Bicycle</OriginalElement>
|
||||
<nodes>
|
||||
<node x="-201.86528497409324" y="25.932642487046632">\DesignPatterns\Creational\FactoryMethod\FactoryMethod</node>
|
||||
<node x="254.01554404145077" y="140.10880829015545">\DesignPatterns\Creational\FactoryMethod\Bicycle</node>
|
||||
<node x="-109.36528497409324" y="183.93264248704662">\DesignPatterns\Creational\FactoryMethod\GermanFactory</node>
|
||||
<node x="251.51554404145077" y="33.10880829015545">\DesignPatterns\Creational\FactoryMethod\VehicleInterface</node>
|
||||
<node x="-279.36528497409324" y="183.93264248704662">\DesignPatterns\Creational\FactoryMethod\ItalianFactory</node>
|
||||
<node x="389.01554404145077" y="140.10880829015545">\DesignPatterns\Creational\FactoryMethod\Ferrari</node>
|
||||
<node x="99.01554404145077" y="130.10880829015545">\DesignPatterns\Creational\FactoryMethod\Porsche</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Creational\FactoryMethod\ItalianFactory" target="\DesignPatterns\Creational\FactoryMethod\FactoryMethod">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="-204.36528497409324" y="158.93264248704662" />
|
||||
<point x="-160.61528497409324" y="158.93264248704662" />
|
||||
<point x="-41.25" y="54.0" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\FactoryMethod\Porsche" target="\DesignPatterns\Creational\FactoryMethod\VehicleInterface">
|
||||
<point x="0.0" y="-44.0" />
|
||||
<point x="166.51554404145077" y="105.10880829015545" />
|
||||
<point x="271.51554404145077" y="105.10880829015545" />
|
||||
<point x="-40.0" y="23.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\FactoryMethod\Bicycle" target="\DesignPatterns\Creational\FactoryMethod\VehicleInterface">
|
||||
<point x="0.0" y="-34.0" />
|
||||
<point x="0.0" y="23.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\FactoryMethod\GermanFactory" target="\DesignPatterns\Creational\FactoryMethod\FactoryMethod">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="-34.36528497409324" y="158.93264248704662" />
|
||||
<point x="-78.11528497409324" y="158.93264248704662" />
|
||||
<point x="41.25" y="54.0" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\FactoryMethod\Ferrari" target="\DesignPatterns\Creational\FactoryMethod\VehicleInterface">
|
||||
<point x="0.0" y="-34.0" />
|
||||
<point x="446.51554404145077" y="105.10880829015545" />
|
||||
<point x="351.51554404145077" y="105.10880829015545" />
|
||||
<point x="40.0" y="23.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="112.5" y="128.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/FactoryMethod/uml/uml.png
Normal file
After Width: | Height: | Size: 16 KiB |
623
Creational/FactoryMethod/uml/uml.svg
Normal file
After Width: | Height: | Size: 74 KiB |
@@ -10,3 +10,7 @@ To have only a list of named instances that are used, like a singleton but with
|
||||
|
||||
* 2 DB Connectors, e.g. one for MySQL, the other for SQLite
|
||||
* multiple Loggers (one for debug messages, one for errors)
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
20
Creational/Multiton/uml/Multiton.uml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\Multiton\Multiton</OriginalElement>
|
||||
<nodes>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\Creational\Multiton\Multiton</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges />
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="118.5" y="85.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/Multiton/uml/uml.png
Normal file
After Width: | Height: | Size: 5.9 KiB |
197
Creational/Multiton/uml/uml.svg
Normal file
After Width: | Height: | Size: 30 KiB |
@@ -6,3 +6,7 @@ The **object pool pattern** is a software creational design pattern that uses a
|
||||
Object pooling can offer a significant performance boost in situations where the cost of initializing a class instance is high, the rate of instantiation of a class is high, and the number of instances in use at any one time is low. The pooled object is obtained in predictable time when creation of the new objects (especially over network) may take variable time.
|
||||
|
||||
However these benefits are mostly true for objects that are expensive with respect to time, such as database connections, socket connections, threads and large graphic objects like fonts or bitmaps. In certain situations, simple object pooling (that hold no external resources, but only occupy memory) may not be efficient and could decrease performance.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
22
Creational/Pool/uml/Pool.uml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\Pool\Processor</OriginalElement>
|
||||
<nodes>
|
||||
<node x="0.0" y="274.0">\DesignPatterns\Creational\Pool\Pool</node>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\Creational\Pool\Processor</node>
|
||||
<node x="242.0" y="274.0">\DesignPatterns\Creational\Pool\Worker</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges />
|
||||
<settings layout="Hierarchic Group" zoom="0.9125295508274232" x="199.5" y="201.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/Pool/uml/uml.png
Normal file
After Width: | Height: | Size: 12 KiB |
467
Creational/Pool/uml/uml.svg
Normal file
After Width: | Height: | Size: 60 KiB |
@@ -7,3 +7,7 @@ To avoid the cost of creating objects the standard way (new Foo()) and instead c
|
||||
## Examples
|
||||
|
||||
* Large amounts of data (e.g. create 1,000,000 rows in a database at once via a ORM).
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
||||
|
35
Creational/Prototype/uml/Prototype.uml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\Prototype\BarBookPrototype</OriginalElement>
|
||||
<nodes>
|
||||
<node x="60.0" y="0.0">\DesignPatterns\Creational\Prototype\BookPrototype</node>
|
||||
<node x="155.0" y="178.0">\DesignPatterns\Creational\Prototype\FooBookPrototype</node>
|
||||
<node x="0.0" y="178.0">\DesignPatterns\Creational\Prototype\BarBookPrototype</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Creational\Prototype\BarBookPrototype" target="\DesignPatterns\Creational\Prototype\BookPrototype">
|
||||
<point x="0.0" y="-34.0" />
|
||||
<point x="67.5" y="153.0" />
|
||||
<point x="102.5" y="153.0" />
|
||||
<point x="-42.5" y="64.0" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\Prototype\FooBookPrototype" target="\DesignPatterns\Creational\Prototype\BookPrototype">
|
||||
<point x="0.0" y="-34.0" />
|
||||
<point x="222.5" y="153.0" />
|
||||
<point x="187.5" y="153.0" />
|
||||
<point x="42.5" y="64.0" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="145.0" y="123.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/Prototype/uml/uml.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
305
Creational/Prototype/uml/uml.svg
Normal file
After Width: | Height: | Size: 42 KiB |
@@ -7,3 +7,7 @@ ConcreteFactory is a simple factory pattern.
|
||||
It differs from the static factory because it is NOT static and as you know: static => global => evil!
|
||||
|
||||
Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock-up it.
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
36
Creational/SimpleFactory/uml/SimpleFactory.uml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\SimpleFactory\ConcreteFactory</OriginalElement>
|
||||
<nodes>
|
||||
<node x="173.0" y="97.0">\DesignPatterns\Creational\SimpleFactory\Scooter</node>
|
||||
<node x="0.0" y="189.0">\DesignPatterns\Creational\SimpleFactory\ConcreteFactory</node>
|
||||
<node x="86.5" y="0.0">\DesignPatterns\Creational\SimpleFactory\VehicleInterface</node>
|
||||
<node x="0.0" y="97.0">\DesignPatterns\Creational\SimpleFactory\Bicycle</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Creational\SimpleFactory\Bicycle" target="\DesignPatterns\Creational\SimpleFactory\VehicleInterface">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="76.5" y="72.0" />
|
||||
<point x="124.75" y="72.0" />
|
||||
<point x="-38.25" y="23.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\SimpleFactory\Scooter" target="\DesignPatterns\Creational\SimpleFactory\VehicleInterface">
|
||||
<point x="0.0" y="-23.5" />
|
||||
<point x="249.5" y="72.0" />
|
||||
<point x="201.25" y="72.0" />
|
||||
<point x="38.25" y="23.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="163.0" y="139.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/SimpleFactory/uml/uml.png
Normal file
After Width: | Height: | Size: 10 KiB |
286
Creational/SimpleFactory/uml/uml.svg
Normal file
After Width: | Height: | Size: 38 KiB |
@@ -12,6 +12,6 @@ To have only one instance of this object in the application that will handle all
|
||||
* 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 ...)
|
||||
|
||||
## Diagram
|
||||
## UML Diagram
|
||||
|
||||
<img src="http://yuml.me/diagram/scruffy/class/[Singleton|-instance: Singleton|+getInstance(): Singleton;-__construct(): void;-__clone(): void;-__wakeup(): void]" >
|
||||

|
20
Creational/Singleton/uml/Singleton.uml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\Singleton\Singleton</OriginalElement>
|
||||
<nodes>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\Creational\Singleton\Singleton</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges />
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="96.0" y="64.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/Singleton/uml/uml.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
162
Creational/Singleton/uml/uml.svg
Normal file
After Width: | Height: | Size: 25 KiB |
@@ -9,3 +9,7 @@ method to create all types of objects it can create. It is usually named `factor
|
||||
## Examples
|
||||
|
||||
* Zend Framework: `Zend_Cache_Backend` or `_Frontend` use a factory method create cache backends or frontends
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
36
Creational/StaticFactory/uml/StaticFactory.uml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Creational\StaticFactory\FormatNumber</OriginalElement>
|
||||
<nodes>
|
||||
<node x="114.0" y="77.0">\DesignPatterns\Creational\StaticFactory\FormatNumber</node>
|
||||
<node x="-8.0" y="149.0">\DesignPatterns\Creational\StaticFactory\StaticFactory</node>
|
||||
<node x="0.0" y="77.0">\DesignPatterns\Creational\StaticFactory\FormatString</node>
|
||||
<node x="43.75" y="0.0">\DesignPatterns\Creational\StaticFactory\FormatterInterface</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Creational\StaticFactory\FormatString" target="\DesignPatterns\Creational\StaticFactory\FormatterInterface">
|
||||
<point x="0.0" y="-13.5" />
|
||||
<point x="47.0" y="52.0" />
|
||||
<point x="75.0" y="52.0" />
|
||||
<point x="-31.25" y="13.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Creational\StaticFactory\FormatNumber" target="\DesignPatterns\Creational\StaticFactory\FormatterInterface">
|
||||
<point x="0.0" y="-13.5" />
|
||||
<point x="165.5" y="52.0" />
|
||||
<point x="137.5" y="52.0" />
|
||||
<point x="31.25" y="13.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="108.5" y="98.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Creational/StaticFactory/uml/uml.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
207
Creational/StaticFactory/uml/uml.svg
Normal file
After Width: | Height: | Size: 27 KiB |
13
More/Delegation/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Delegation
|
||||
|
||||
## Purpose
|
||||
|
||||
...
|
||||
|
||||
## Examples
|
||||
|
||||
...
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
21
More/Delegation/uml/Delegation.uml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\More\Delegation\JuniorDeveloper</OriginalElement>
|
||||
<nodes>
|
||||
<node x="-8.0" y="134.0">\DesignPatterns\More\Delegation\JuniorDeveloper</node>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\More\Delegation\TeamLead</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges />
|
||||
<settings layout="Hierarchic Group" zoom="1.0" x="68.5" y="90.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
More/Delegation/uml/uml.png
Normal file
After Width: | Height: | Size: 5.8 KiB |
196
More/Delegation/uml/uml.svg
Normal file
After Width: | Height: | Size: 28 KiB |
@@ -10,3 +10,7 @@ Repository also supports the objective of achieving a clean separation and one-w
|
||||
|
||||
* Doctrine 2 ORM: there is Repository that mediates between Entity and DBAL and contains methods to retrieve objects
|
||||
* Laravel Framework
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
28
More/Repository/uml/Repository.uml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Repository\PostRepository</OriginalElement>
|
||||
<nodes>
|
||||
<node x="415.0" y="0.0">\DesignPatterns\Repository\Storage</node>
|
||||
<node x="405.0" y="137.0">\DesignPatterns\Repository\MemoryStorage</node>
|
||||
<node x="0.0" y="0.0">\DesignPatterns\Repository\Post</node>
|
||||
<node x="0.0" y="373.0">\DesignPatterns\Repository\PostRepository</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Repository\MemoryStorage" target="\DesignPatterns\Repository\Storage">
|
||||
<point x="0.0" y="-74.5" />
|
||||
<point x="0.0" y="43.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="0.7394636015325671" x="299.5" y="251.0" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
More/Repository/uml/uml.png
Normal file
After Width: | Height: | Size: 26 KiB |
687
More/Repository/uml/uml.svg
Normal file
After Width: | Height: | Size: 89 KiB |
@@ -14,3 +14,7 @@ Service Locator object on bootstrap.
|
||||
## Examples
|
||||
|
||||
* Zend Framework 2 uses Service Locator to create and share services used in the framework(i.e. EventManager, ModuleManager, all custom user services provided by modules, etc...)
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
38
More/ServiceLocator/uml/ServiceLocator.uml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\More\ServiceLocator\DatabaseServiceInterface</OriginalElement>
|
||||
<nodes>
|
||||
<node x="276.0" y="0.0">\DesignPatterns\More\ServiceLocator\DatabaseServiceInterface</node>
|
||||
<node x="22.5" y="408.0">\DesignPatterns\More\ServiceLocator\LogService</node>
|
||||
<node x="0.0" y="117.0">\DesignPatterns\More\ServiceLocator\ServiceLocator</node>
|
||||
<node x="41.5" y="0.0">\DesignPatterns\More\ServiceLocator\ServiceLocatorInterface</node>
|
||||
<node x="0.0" y="331.0">\DesignPatterns\More\ServiceLocator\LogServiceInterface</node>
|
||||
<node x="298.5" y="77.0">\DesignPatterns\More\ServiceLocator\DatabaseService</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\More\ServiceLocator\ServiceLocator" target="\DesignPatterns\More\ServiceLocator\ServiceLocatorInterface">
|
||||
<point x="0.0" y="-84.5" />
|
||||
<point x="0.0" y="33.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\More\ServiceLocator\DatabaseService" target="\DesignPatterns\More\ServiceLocator\DatabaseServiceInterface">
|
||||
<point x="0.0" y="-13.5" />
|
||||
<point x="0.0" y="13.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\More\ServiceLocator\LogService" target="\DesignPatterns\More\ServiceLocator\LogServiceInterface">
|
||||
<point x="0.0" y="-13.5" />
|
||||
<point x="0.0" y="13.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="0.8483516483516483" x="217.0" y="217.5" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
More/ServiceLocator/uml/uml.png
Normal file
After Width: | Height: | Size: 14 KiB |
432
More/ServiceLocator/uml/uml.svg
Normal file
After Width: | Height: | Size: 53 KiB |
@@ -8,3 +8,7 @@ To translate one interface for a class into a compatible interface. An adapter a
|
||||
|
||||
* DB Client libraries adapter
|
||||
* using multiple different webservices and adapters normalize data so that the outcome is the same for all
|
||||
|
||||
## UML Diagram
|
||||
|
||||

|
41
Structural/Adapter/uml/Adapter.uml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Diagram>
|
||||
<ID>PHP</ID>
|
||||
<OriginalElement>\DesignPatterns\Structural\Adapter\Book</OriginalElement>
|
||||
<nodes>
|
||||
<node x="0.0" y="117.0">\DesignPatterns\Structural\Adapter\EBookAdapter</node>
|
||||
<node x="173.0" y="138.0">\DesignPatterns\Structural\Adapter\Book</node>
|
||||
<node x="-8.0" y="388.0">\DesignPatterns\Structural\Adapter\Kindle</node>
|
||||
<node x="-8.0" y="271.0">\DesignPatterns\Structural\Adapter\EBookInterface</node>
|
||||
<node x="85.75" y="0.0">\DesignPatterns\Structural\Adapter\PaperBookInterface</node>
|
||||
</nodes>
|
||||
<notes />
|
||||
<edges>
|
||||
<edge source="\DesignPatterns\Structural\Adapter\EBookAdapter" target="\DesignPatterns\Structural\Adapter\PaperBookInterface">
|
||||
<point x="0.0" y="-54.5" />
|
||||
<point x="80.5" y="92.0" />
|
||||
<point x="125.75" y="92.0" />
|
||||
<point x="-32.0" y="33.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Structural\Adapter\Book" target="\DesignPatterns\Structural\Adapter\PaperBookInterface">
|
||||
<point x="0.0" y="-33.5" />
|
||||
<point x="235.0" y="92.0" />
|
||||
<point x="189.75" y="92.0" />
|
||||
<point x="32.0" y="33.5" />
|
||||
</edge>
|
||||
<edge source="\DesignPatterns\Structural\Adapter\Kindle" target="\DesignPatterns\Structural\Adapter\EBookInterface">
|
||||
<point x="0.0" y="-33.5" />
|
||||
<point x="0.0" y="33.5" />
|
||||
</edge>
|
||||
</edges>
|
||||
<settings layout="Hierarchic Group" zoom="0.8126315789473684" x="144.5" y="227.50000000000003" />
|
||||
<SelectedNodes />
|
||||
<Categories>
|
||||
<Category>Fields</Category>
|
||||
<Category>Constants</Category>
|
||||
<Category>Constructors</Category>
|
||||
<Category>Methods</Category>
|
||||
</Categories>
|
||||
<VISIBILITY>private</VISIBILITY>
|
||||
</Diagram>
|
||||
|
BIN
Structural/Adapter/uml/uml.png
Normal file
After Width: | Height: | Size: 13 KiB |
448
Structural/Adapter/uml/uml.svg
Normal file
After Width: | Height: | Size: 60 KiB |