On 12 Okt., 11:19, Kevin Wright <[email protected]> wrote:
> Where are the uninitialised values being exposed?
Let me quote my first response:
> No[t] a big deal because nobody can observe this state, however, once one
> gets into initializing immutable object graphs things get very hairy very
> quickly:
It's not so much about what is exposed to library consumers, but
rather what the library developer can observe. Obviously an immutable
object should /appear/ to never change, but my whole point is that it
does anyway. And it's extremely difficult to prove that complex object
graphs (potentially containing multiple cycles) end up with all fields
correctly initialized.
A classic example is phased initialization. First you create the
object graph, a set of objects V with arbitrary relationships between
elements of V. Then you establish invariant I_1 for all elements of V,
then invariant I_2, and so on and so forth until you reach I_n. At
that point all elements in V are in fully initialized. An example of
such object graphs is the Java type system: Only after you created all
types and their parameters can you initialize theirs supertypes (and
bounds respectively).
interface I<T extends I<T>> {}
class A implements I<B> {}
class B extends A {}
With kind regards
Ben
--
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en.