Creational Patterns  «Prev  Next»
Lesson 4Common creational patterns
ObjectiveDescribe, Compare, and Contrast several Creational Patterns.

Describe, Compare, and Contrast several Creational Patterns

There is no particular limit to the number of creational patterns, any more than there is a finite number of possible blueprints for a house, there are five which are particularly well-known.
  1. Factory Method pattern
  2. Abstract Factory
  3. Builder
  4. Prototype
  5. Singleton

We have already looked at the Singleton pattern. Later in this module, you will have a chance to explore the Factory Method pattern in detail.
The other three common creational patterns are described in this SlideShow:




Microservices Patterns
  1. Abstract Factory pattern defines an interface for creating instances of several related abstract classes without specifying their concrete subclasses. The java.awt.Toolkit class used to create native peers for graphical user interface components is an example of an abstract factory class.
  2. Builder Pattern builds different complex objects from the same set of component parts. For example, the Director class might feed a long list of names and addresses into the Builder. The Builder might build an HTML page from that list, an XML page, or a PostScript file, depending on what type of Builder it was.
  3. The Prototype pattern creates new objects by copying a prototype object. By changing the object that is copied, you change the object that is created. This is useful when you need many different copies of a relatively complex object, all of which have the same initial state.

Three Design Patterns.
Creational: This deals with the concept of how an object can be created.
This often involves isolating the details of object creation so your code is not dependent on what types of objects there are and thus does not have to be changed when you add a new type of object. The aforementioned Singleton is classified as a creational pattern, and later in this course you will see examples of the Factory Method and Prototype.

Common Creational Patterns - Quiz

Click the link below to take a short quiz on the material just covered.
Common Creational Patterns - Quiz