Monday, October 26, 2009

Chapter 5: Creational Patterns




















Chapter 5 -
Creational Patterns
Patterns in Java, Volume 1: A Catalog of Reusable Design Patterns Illustrated with UML, Second Edition
by Mark Grand
John Wiley & Sons � 2002


























Chapter 5: Creational Patterns




Overview



Creational patterns provide guidance on how to create objects when their creation requires making decisions. These decisions will typically involve dynamically deciding which class to instantiate or which objects an object will delegate responsibility to. The value of creational patterns is to tell us how to structure and encapsulate these decisions.


Often, there is more than one creational pattern that you can apply to a situation. Sometimes you can combine multiple patterns advantageously. In other cases, you must choose between competing patterns. For these reasons, it is important to be acquainted with all of the patterns described in this chapter.


If you have time to learn only one pattern in this chapter, the most commonly used one is Factory Method. The Factory Method pattern is a way for an object to initiate the creation of another object without having to know the class of the object created.


The Abstract Factory pattern is a way for objects to initiate the creation of a variety of different kinds of objects without knowing the classes of the objects created, but ensuring that the classes are a correct combination.


The Builder pattern is a way to determine the class of an object created by its contents or context.


The Prototype pattern allows an object to create customized objects without knowing their exact class or the details of how to create them.


The Singleton pattern is a way for multiple objects to share a common object without having to know whether it already exists.


The Object Pool pattern is a way to reuse objects rather than create new objects.
















No comments: