Reference types, Value types, and Patterns - slide 27 : 29 |
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