CSE Roadmap

Core tier · about 3 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes first in Level 3

In this module you will

  • Explain why calling new on a concrete class ties code to that class.
  • Write a static factory method and name three advantages over a constructor.
  • Write a simple factory and say why it is an idiom and not a pattern.
  • Write the Factory Method pattern with a creator and its subclasses.
  • Choose between the three for a given situation.

Module 5 of Level 2 said that important code should not name volatile concrete classes. Creating an object needs the class name, so creation is where that rule gets hard. The sources are "Effective Java" (EJ) Item 1, "Head First Design Patterns" (HF) chapter 4, and "Design Patterns" (GoF) chapter 3. Code was compiled and run before it was written here. Numbers marked "made up" only show the idea.