This document discusses several design patterns:
1) Factory method is a class with methods to create objects.
2) Command represents operations as objects to call methods later.
3) Chain of responsibility shares requests along a chain until handled.
Design Patterns Un design pattern o patrón de diseño es una solución reutilizable frente a problemas frecuentes en el diseño de software.
3.
¿Por qué utilizarlos?Acelera el desarrollo Soluciones probadas frente a paradigmas de desarrollo Mejora la legibilidad del código
4.
Factory method Elfactory pattern es una clase que tiene una sierie de methods que permiten crear objetos.
5.
6.
7.
8.
9.
10.
Command Un objetoes 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.
11.
12.
13.
Cadena de responsabilidadesAvoid 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..
14.
15.
This pattern sharessome 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.
16.
Decorator Attach additionalresponsibilities 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”
17.
18.
Composite The compositepattern 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.
19.
20.
State Allow anobject to alter its behavior when its internal state changes. The object will appear to change its class.