Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: Interface with implied Constructor Date: Fri, 19 Jul 2013 21:21:32 +0000 (UTC) Organization: A noiseless patient Spider Lines: 39 Message-ID: References: <925adeb1-65b5-4a50-86a8-4f04784f8da0@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 19 Jul 2013 21:21:32 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="4941"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xIscHeJgf46SpDUl9HofzyVXKXgmafCA=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:08KYW1GlEyraqdsO54cY2F12ZRE= Xref: csiph.com comp.lang.java.programmer:24763 On Fri, 19 Jul 2013 12:38:19 -0700, Gene Wirchenko wrote: > On Thu, 18 Jul 2013 23:21:35 -0300, Arved Sandstrom > wrote: > > [snip] > >>I'll be honest, Robert, personally I consider the behaviour of an object >>- the kinds of things you could specify in an interface - to be what the >>*initialized* object can (should) do. > > But there is more to it than that. There is also getting it > initialised. That should also be part of the API. I would not enforce > that it has to, but I sure would like the option to specify constructor > signatures in an interface. > Yes, agreed. I tend to extend superclasses instead of using an interface for exactly that reason. >>I seriously dislike init() methods, not just in Java. Particularly if >>there is no sensible un-init()'ed object for the class. I just don't see >>any credible argument for them. Like Richard said, actually: >>"half-baked". >> I take the opposite approach to Robert over that for one reason: that the only way to report init errors in a constructor is to throw an Exception, which means the instance declaration often needs to go inside a try/catch block which can screw up scoping. If init errors are possible and must be caught, I prefer to use a constructor that can't do anything that needs an Exception to be thrown and finish the job with an init() method that can go in the following try/catch block along with (some of) the other method calls. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |