in reply to Constructor/Factory Orthodoxy
It's largely a matter of convention and expectation. When I write
I expect to get a Frob, and future readers of the code might reasonably expect that $frob will hold an instance of Frob. But if I writemy $frob = new Frob();
there is no such assumption. Nobody is misled. At most, the assumption is that $frob will get a Frob or a subclass of Frob.my $frob = Frob::makeFrob();
Having new work consistently 99% of the time is a bad thing. It lulls people into traps.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Constructor/Factory Orthodoxy
by mojotoad (Monsignor) on Feb 26, 2003 at 00:22 UTC | |
by dws (Chancellor) on Feb 26, 2003 at 00:25 UTC | |
|
(Re:)+ Constructor/Factory Orthodoxy
by rir (Vicar) on Feb 26, 2003 at 22:38 UTC | |
by dws (Chancellor) on Feb 26, 2003 at 22:54 UTC | |
by rir (Vicar) on Feb 26, 2003 at 23:38 UTC | |
by dragonchild (Archbishop) on Feb 27, 2003 at 14:27 UTC |