Reusable Design Patterns
The design patterns help to resolve recurrent problems in object
programming,
in the form of micro-architectures. The main patterns are described in
the reference book :
- E. Gamma, R. Helm, R. Johnson et J. Vlissides, "Design patterns:
Elements of reusable object-oriented software",
Addison-Wesley Professional 1994.
In this page, we give the list of the models presented in the course
with UML diagrams or the corresponding classes in the Java API.
Iterator
- Intent : "Provide a way to
access the elements of an aggregate object
sequentially without exposing its underlying representation."
- Implementation in the Java API :
java.util.Iterator
Adapter
- Intent : "Convert the
interface of a class into another interface clients expect. Adapter
lets classes work together that couldn't otherwise because of
incompatible interfaces."
- There are two kinds of adapters : adapters for objects or
adapters
for classes. The first uses delegation, the second inheritance.
Decorator
- Intent : "Attach additional
responsibilities to an object dynamically. Decorators provide a
flexible alternative to subclassing for extending functionality."
- Example in the Java API : the class
java.io.BufferedReader
is a decorator for instances of the interface java.io.Reader
.
Observer
- Intent : "Define a one-to-many
dependency between objects so that when one object changes state, all
its dependents are notified and updated automatically."
- Implementation in the Java API :
java.util.Observer
and java.util.Observable