09 Prove
Factory Pattern
Objectives
Learn about the Factory pattern.
Introduction
The Factory pattern is a very, very common pattern in Java. So common in fact, that there's a popular meme about it:
The purpose of the factory pattern is to provide an abstraction layer about how objects are created. This allows several advantages. Two of the most common are:
It allows us to use polymorphism quite easily.
-
It gives us an easy way to simplify the creation of complex object hierarchies (where one object depends upon several others).
Assignment
-
Read this overview of the Factory pattern.
-
Take a look at this example of when to use the Factory pattern.
-
Read this StackOverflow post, which discusses the three most common variations of the Factory pattern.
Make sure to complete the accompanying quiz for this assignment on I-Learn.