Re: Could an object refuse to be created!?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Sunny (sunnyask_at_icebergwireless.com)
Date: 05/16/04


Date: Sun, 16 May 2004 08:53:10 -0500

Good point.
Sunny

Justin Rogers wrote:

> Would be nice to note, that in cases where your object creation is linked
> to valid input criterion, that you might instead use a factory method.
> Factory methods demonstrate, better than constructors, that work is going
> to occur
> and that validation of parameters might be necessary. Factory methods are
> also capable of returning null rather than throwing an exception. To then
> prevent the user from instantiating your type directly, you simply
> privatize the constructor.
>
>



Relevant Pages

  • Re: Constructor or getInstance() method
    ... Minus java.util.Calendar (it has protected constructors) and plus ... >> reasons to have both public constructors and factory methods. ... > can be distinguished even if their signatures are identical. ... > form, plus `static Complex polar' ...
    (comp.lang.java.programmer)
  • Re: General rule for constructors
    ... work out the ratio of public constructors to factory methods. ... Connection con = DriverManager.getConnection; ...
    (comp.lang.java.programmer)
  • Re: General rule for constructors
    ... work out the ratio of public constructors to factory methods. ...
    (comp.lang.java.programmer)
  • Re: Could an object refuse to be created!?
    ... Justin Rogers wrote: ... > to valid input criterion, that you might instead use a factory method. ... > methods demonstrate, better than constructors, that work is going to occur ...
    (microsoft.public.dotnet.languages.csharp)