Calidad, en informática siempre va ligado a mantenibilidad y explotación; si un código no es mantenible , extensible y explotable de forma óptima seguro que no estará correctamente diseñado.
Este libro prestado, cortesía de un compañero y amigo (RamonMaría), nos detalla de forma amena, los principales patrones de programación con ejemplos através de un lenguaje de proposito general como Java, pero que se puede trasladar a cualquier lenguaje que disponga de los principios fundamentales de la OO. Es un libro muy básico para entrar en el mundo de los patrones pero que permite orientar al analista informático hacia el camino de la iluminación del código de calidad.
Aquí os dejo el pequeño resumen que he realizado en su versión original , un inglés muy básico que se lee con facilidad...
Extracto de “Head First Design Patterns”
The context is the situation in which the pattern applies. This should be a recurring situation.
The problem refers to the goal you are trying to achieve in this context, but it also refers to any constraints that occur in the context.
The solution is what you’re after:a general design that anyone can apply which resolves the goal and set of constraints.
- Identify the aspects of your application that vary and separate them from what stays the same.
- Program to an interace, not an implementation. (“Program to an interface” really menas “Program to a supertype”).
- Favor composition over inheritance.
- Strive for llosely coupled designs between objects that interact.
- Classes should be open for extension, but closed for modification.
- Depend upon abstractions. Do not depend upon concrete classes.
- Principle of Least Knowledge talk only to your immediate friends.
- The Hollywood Principle : Don’t call us, we’ll call you.
- A class should have only one reason to change.
The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.
Bridge : Use the Bridge Pattern to vary not only your implementations, buy also your abstractions.
Builder : use the Builder Pattern to encapsulate the construction of a product and allow it to be constructed in steps.
Chain of Responsibility : use the Chain of Responsability Pattern when you want to give more than one object a chance to handle a request.
Flyweight : Use the Flyweight Pattern when one instance of a class can be used to provide many “virtual instances”.
Interpreter : Use the Interpreter Pattern to build an interpreter for a language.
Mediator : Use the Mediator Pattern to centralize complex communications and control between related objects.
Memento : Use the Memento Pattern when you need to be able to return an object to one of its previous states; for instance, if your user requests an “undo”.
Prototype : Use the Prototyp Pattern when creating an instance of a given class is either expensive or complicated.
Visitor : Use the Visitor Pattern when you want to add capabilities to a composite of objects and encapsulation is not important.
No hay comentarios:
Publicar un comentario