in reply to Re: Leaving a constructor midway?
in thread OO: Leaving a constructor midway?
Factory methods are just as flexible though and I usually favor them over constructors anyway since they give you a lot more control over what specific object you are creating. For instance, a factory method can create and return a specific subtype of the object you want and you can swap out that specific subtype (to change underlying implementation) easily without breaking client code. Similarly with turning a class into a singleton.
|
|---|