Skip to content

Commit de431c5

Browse files
author
John Webb
committed
Added More pattern UMLs
1 parent 3a35fa7 commit de431c5

File tree

33 files changed

+1508
-2
lines changed

33 files changed

+1508
-2
lines changed

Behavioral/ChainOfResponsibilities/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ To build a chain of objects to handle a call. If one object cannot handle a call
1010
* a Spam filter
1111
* Caching: first object is an instance of e.g. a Memcached Interface, if that "misses" it delegates the call to the database interface
1212
* 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.
13+
14+
## UML Diagram
15+
16+
![Alt ChainOfResponsibility UML Diagram](uml/uml.png)

Behavioral/Command/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ Command can also be aggregated to combine more complex commands with minimum cop
1515
* A text editor : all events are Command which can be undone, stacked and saved.
1616
* Symfony2: SF2 Commands that can be run from the CLI are built with just the Command pattern in mind
1717
* 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)
18+
19+
## UML Diagram
20+
21+
![Alt Command UML Diagram](uml/uml.png)

Behavioral/Iterator/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ To make an object iterable and to make it appear like a collection of objects.
1111
## Note
1212

1313
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
14+
15+
## UML Diagram
16+
17+
![Alt Iterator UML Diagram](uml/uml.png)

Behavioral/Mediator/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ like a controller (but not in the sense of the MVC).
99
All components (called Colleague) are only coupled to the MediatorInterface and
1010
it is a good thing because in OOP, one good friend is better than many. This
1111
is the key-feature of this pattern.
12+
13+
## UML Diagram
14+
15+
![Alt Mediator UML Diagram](uml/uml.png)

Behavioral/Memento/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ When using this pattern, care should be taken if the originator may change other
1616

1717
* The seed of a pseudorandom number generator
1818
* The state in a finite state machine
19+
20+
## UML Diagram
21+
22+
![Alt Momento UML Diagram](uml/uml.png)

Behavioral/NullObject/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ a statement like `if (!is_null($obj)) { $obj->callSomething(); }` anymore.
1818
* Symfony2: null output in Symfony/Console
1919
* null handler in a Chain of Responsibilities pattern
2020
* null command in a Command pattern
21+
22+
## UML Diagram
23+
24+
![Alt NullObject UML Diagram](uml/uml.png)

Behavioral/Observer/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ To implement a publish/subscribe behaviour to an object, whenever a "Subject" ob
1111

1212
## Note
1313

14-
PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject.
14+
PHP already defines two interfaces that can help to implement this pattern: SplObserver and SplSubject.
15+
16+
## UML Diagram
17+
18+
![Alt Observer UML Diagram](uml/uml.png)

Behavioral/Specification/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
Builds a clear specification of business rules, where objects can be checked against. The composite specification class has
66
one method called `isSatisfiedBy` that returns either true or false depending on whether the given object satisfies the specification.
77

8+
## UML Diagram
9+
10+
![Alt Specification UML Diagram](uml/uml.png)

Behavioral/State/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
## Purpose
44

55
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.
6+
7+
## UML Diagram
8+
9+
![Alt State UML Diagram](uml/uml.png)

Behavioral/Strategy/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ To separate strategies and to enable fast switching between them. Also this patt
1414

1515
* sorting a list of objects, one strategy by date, the other by id
1616
* simplify unit testing: e.g. switching between file and in-memory storage
17+
18+
## UML Diagram
19+
20+
![Alt Strategy UML Diagram](uml/uml.png)

Behavioral/TemplateMethod/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ How? With abstraction of course.
1212
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.
1313

1414
It is an easy way to decouple concrete classes and reduce copy-paste, that's why you'll find it everywhere.
15+
16+
## UML Diagram
17+
18+
![Alt TemplateMethod UML Diagram](uml/uml.png)

Behavioral/Visitor/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ The Visitor Pattern lets you outsource operations on objects to other objects. T
66
But classes have to define a contract to allow visitors (the `Role::accept` method in the example).
77

88
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.
9+
10+
## UML Diagram
11+
12+
![Alt Visitor UML Diagram](uml/uml.png)

Creational/AbstractFactory/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44

55
To create series of related or dependent objects without specifying their concrete classes.
66
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.
7+
8+
## UML Diagram
9+
10+
![Alt AbstractFactory UML Diagram](uml/uml.png)

Creational/Builder/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ Note: Builders have often a fluent interface, see the mock builder of PHPUnit fo
1313
## Examples
1414

1515
* PHPUnit: Mock Builder
16+
17+
## UML Diagram
18+
19+
![Alt Builder UML Diagram](uml/uml.png)

Creational/FactoryMethod/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ For simple case, this abstract class could be just an interface
99
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.
1010

1111
It means the FactoryMethod class depends on abstractions, not concrete classes. This is the real trick compared to SimpleFactory or StaticFactory.
12+
13+
## UML Diagram
14+
15+
![Alt FactoryMethod UML Diagram](uml/uml.png)

Creational/Multiton/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ To have only a list of named instances that are used, like a singleton but with
1010

1111
* 2 DB Connectors, e.g. one for MySQL, the other for SQLite
1212
* multiple Loggers (one for debug messages, one for errors)
13+
14+
## UML Diagram
15+
16+
![Alt Multiton UML Diagram](uml/uml.png)

Creational/Pool/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ The **object pool pattern** is a software creational design pattern that uses a
66
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.
77

88
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.
9+
10+
## UML Diagram
11+
12+
![Alt Pool UML Diagram](uml/uml.png)

Creational/Prototype/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ To avoid the cost of creating objects the standard way (new Foo()) and instead c
77
## Examples
88

99
* Large amounts of data (e.g. create 1,000,000 rows in a database at once via a ORM)
10+
11+
## UML Diagram
12+
13+
![Alt Prototype UML Diagram](uml/uml.png)

Creational/SimpleFactory/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ ConcreteFactory is a simple factory pattern.
77
It differs from the static factory because it is NOT static and as you know: static => global => evil!
88

99
Therefore, you can have multiple factories, differently parametrized, you can subclass it and you can mock-up it.
10+
11+
## UML Diagram
12+
13+
![Alt SimpleFactory UML Diagram](uml/uml.png)

Creational/Singleton/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ To have only one instance of this object in the application that will handle all
1414

1515
## Diagram
1616

17-
<img src="http://yuml.me/diagram/scruffy/class/[Singleton|-instance: Singleton|+getInstance(): Singleton;-__construct(): void;-__clone(): void;-__wakeup(): void]" >
17+
<img src="http://yuml.me/diagram/scruffy/class/[Singleton|-instance: Singleton|+getInstance(): Singleton;-__construct(): void;-__clone(): void;-__wakeup(): void]" >
18+
19+
## UML Diagram
20+
21+
![Alt Singleton UML Diagram](uml/uml.png)

Creational/StaticFactory/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ method to create all types of objects it can create. It is usually named `factor
99
## Examples
1010

1111
* Zend Framework: `Zend_Cache_Backend` or `_Frontend` use a factory method create cache backends or frontends
12+
13+
## UML Diagram
14+
15+
![Alt StaticFactory UML Diagram](uml/uml.png)

More/Delegation/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Delegation
2+
3+
## Purpose
4+
5+
...
6+
7+
## Examples
8+
9+
...
10+
11+
## UML Diagram
12+
13+
![Alt Delegation UML Diagram](uml/uml.png)

More/Delegation/uml/Delegation.uml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Diagram>
3+
<ID>PHP</ID>
4+
<OriginalElement>\DesignPatterns\More\Delegation\JuniorDeveloper</OriginalElement>
5+
<nodes>
6+
<node x="-8.0" y="134.0">\DesignPatterns\More\Delegation\JuniorDeveloper</node>
7+
<node x="0.0" y="0.0">\DesignPatterns\More\Delegation\TeamLead</node>
8+
</nodes>
9+
<notes />
10+
<edges />
11+
<settings layout="Hierarchic Group" zoom="1.0" x="68.5" y="90.5" />
12+
<SelectedNodes />
13+
<Categories>
14+
<Category>Fields</Category>
15+
<Category>Constants</Category>
16+
<Category>Constructors</Category>
17+
<Category>Methods</Category>
18+
</Categories>
19+
<VISIBILITY>private</VISIBILITY>
20+
</Diagram>
21+

More/Delegation/uml/uml.png

5.79 KB
Loading

0 commit comments

Comments
 (0)