Added More pattern UMLs

This commit is contained in:
John Webb
2014-07-31 14:13:53 -05:00
parent 3a35fa7ef6
commit de431c5126
33 changed files with 1508 additions and 2 deletions

View File

@@ -10,3 +10,7 @@ To build a chain of objects to handle a call. If one object cannot handle a call
* 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
![Alt ChainOfResponsibility UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Command UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Iterator UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Mediator UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Momento UML Diagram](uml/uml.png)

View File

@@ -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
![Alt NullObject UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Observer UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Specification UML Diagram](uml/uml.png)

View File

@@ -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
![Alt State UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Strategy UML Diagram](uml/uml.png)

View File

@@ -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
![Alt TemplateMethod UML Diagram](uml/uml.png)

View File

@@ -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
![Alt Visitor UML Diagram](uml/uml.png)