Software Design and Development :: CS 246

09 Prove

Factory Pattern

Objectives

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:

  1. It allows us to use polymorphism quite easily.

  2. It gives us an easy way to simplify the creation of complex object hierarchies (where one object depends upon several others).

Assignment

  1. Read this overview of the Factory pattern.

  2. Take a look at this example of when to use the Factory pattern.

  3. 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.