Lecture overview -- Keyboard shortcut: 'u'  Previous page: A Singleton Random Class -- Keyboard shortcut: 'p'  Next page: Examples of Static Factory Methods -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Reference types, Value types, and Patterns - slide 27 : 29

Factory methods

Problem: If many instances of the expression new C(...) are sprinkled across a program we have very strong bindings to creation of C - as opposed to an alternative class D

It is sometimes awkward to program adequate constructors because we cannot chose good name for them, and we cannot always control the parameters of constructors

Solution: Create objects via one or more factory methods - typically class methods

There exist related object-oriented design patterns called Factory Method and Abstract Factory, both of which involve inheritance