Design patterns
-
Upload
avature -
Category
Technology
-
view
404 -
download
0
Transcript of Design patterns
Design PatternsPHP
Un design pattern o patrón de diseño es una solución
reutilizable frente a problemas frecuentes en el
diseño de software.
Design Patterns
¿Por qué utilizarlos?
Acelera el desarrollo
Soluciones probadas frente a paradigmas de desarrollo
Mejora la legibilidad del código
Factory method
El factory pattern es una clase que tiene una sierie de methods que permiten
crear objetos.
Command
Un objeto es utilizado para representar y encapsular todo la información necesaria para
llamar luego a un method. Esta información incluye el method name, el objeto dueño del
method y los valores los parámetros del method.
Cadena de responsabilidades
Avoid coupling the sender of a request to its receiver by giving more than one object a
chance to handle a request. Chain the receiving objects and pass the request along the chain
until an object handles it.A mechanism also exists for adding new
processing objects to the end of this chain.
Variación: árbol de responsabilidad..
This pattern shares some structural similarities with Java exceptions: either they are handled or passed on.
This pattern is useful for hierarchical structures where a request can be handled at multiple layers.
Like our GUI event handling is done hierarchically. If an object doesn't want to handle an event it can delegate it to its parent, up the chain.
Decorator
Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending
functionality
The original code is open to extension but closed to modification
“Open/closed principle”
CompositeThe composite pattern describes that a group of objects are to be treated in the same way as a
single instance of an object.Compose objects into tree structures to
represent part-whole hierarchies. Composite lets clients treat individual objects and
compositions of objects uniformly.
State
Allow an object to alter its behavior when its internal state changes.
The object will appear to change its class.