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 and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 27 : 29
Object-oriented Programming in C#
Reference types, Value types, and Patterns
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