Factory method pattern: Difference between revisions

Content deleted Content added
Rewrote article
Descriptive names: Add comment on private constructors
Line 98:
Complex c = Complex.fromPolar(1, pi); // Same as fromCartesian(-1, 0)
 
When factory methods are used for disambiguation like this, the constructor is often made private to force clients to use the factory methods.
 
===Encapsulation===