Re: Convenience constructors and non-final setters



On Thu, 5623 Sep 1993 14:58:59 +0000, Andreas Leitgeb wrote:
Joshua Cranmer <Pidgeot18@xxxxxxxxxxxxxxx> wrote:
Andreas Leitgeb wrote:
Having to call setSeed() explicitly on user's side would have impacted
comfort severely (ok, I guess that argument doesn't count for OO-purists),
and determining the need to call it lazily only on each invocation of
next() would have been a performance issue. (another argument likely
not shared by OO-purists)
Are there even other ways out? (even if we could turn back time?)

I think the "cleanest" way out would have been to provide a protected
init() method which would have been called before setSeed.

But that would still have broken the rule:
"no non-final (& non-private) method calls from constructor"

True. I think his point is that it might have mitigated the consequences,
IF subclass writers had their constructors only call super and do any
post-setSeed initialization, while doing all of their pre-setSeed
initialization in an overridden init() method. Then the superclass
constructor runs, init() runs, setSeed() runs, and the subclass
constructor runs.

It still stinks, though opinions may vary as to whether it stinks half as
bad or twice as bad. In my opinion they should have made Random abstract,
or even an interface. An abstract Random with a getInstance factory method
would have been cleaner than the mess we actually got.

--
blue indigo
UA Telecom since 1987
.



Relevant Pages

  • Re: All those constructors...
    ... > I have this fairly large class heirarchy, ... creating package visible setXXX() for the init parameters ... creating a public init() method which subclasses use for their constructor ...
    (comp.lang.java.programmer)
  • Re: is such exception handling approach good?
    ... an oracle database in the ctor then what should you do ... of them in constructor; sometimes all of them. ... void AllInOne::RetrieveData ... assert("Cannot init the buffer twice!"); ...
    (microsoft.public.vc.language)
  • Re: is such exception handling approach good?
    ... "Alex Blekhman" wrote: ... of them in constructor; sometimes all of them. ... void AllInOne::RetrieveData ... assert("Cannot init the buffer twice!"); ...
    (microsoft.public.vc.language)
  • Re: Error - Declaring static arrays of structs in a class (VC6)
    ... But I think it is also a good style to supply a constructor, and init the ... VC 7.1 is sometimes too forgiving to not-so-good style code. ...
    (microsoft.public.vc.language)
  • Re: Remoting service wont start
    ... I often see those kinds of errors in services because of things like syntax errors in the App.config file, or in the constructor, or on init. ... Does anyone know what might be causing it? ...
    (microsoft.public.dotnet.general)