Re: Defining a constructor in an Interface
- From: bcd@xxxxxxxxxxx (Bent C Dalager)
- Date: Thu, 30 Jun 2005 09:11:11 +0000 (UTC)
In article <42C33E26.3F01@xxxxxxxxxxxxx>,
Lee Fesperman <firstsql@xxxxxxxxxxxxx> wrote:
>
>As others have suggested, require a no-args constructor and define a
>class initializer
>in the interface, like init(...). It really is a better way.
I have based my (non-factory-based) immutables on getting all their
state through the ctor, but the question posed indicates that this
isn't always feasible.
Is an init() method considered a viable way to make immutable objects?
While you could write init() in such a way that any calls beyond the
first are ignored, it seems a bit kludgy. If nothing else, clients
could end up using instances that haven't had init() called on them
yet and then their contents _can_ theoretically change at some later
point.
Cheers
Bent D
--
Bent Dalager - bcd@xxxxxxx - http://www.pvv.org/~bcd
powered by emacs
.
- References:
- Defining a constructor in an Interface
- From: Chris Berg
- Re: Defining a constructor in an Interface
- From: Lee Fesperman
- Defining a constructor in an Interface
- Prev by Date: Re: A button close in JDialog
- Next by Date: Re: How to get file extention from Content-type.
- Previous by thread: Re: Defining a constructor in an Interface
- Next by thread: Re: Defining a constructor in an Interface
- Index(es):