directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Karasulu <>
Subject Re: Immutable objects, what's best ?
Date Sun, 14 Mar 2010 10:44:00 GMT
On Sun, Mar 14, 2010 at 10:46 AM, Stefan Seelmann <> wrote:
> Emmanuel Lecharny schrieb:
>> Hi,
>> we have many objects that we want to be immutable. What's the best solution
>> to produce  those immutable objets ?
>> - For DN, we would like to use valueOf(), and the DN() constructor, but no
>> setter
>> - For Entry, a constructor is not enough, as we may have to inject new
>> attributes. We may need to have two different classes, one immutable, one
>> mutable. The immutable class could be associated with a factory, or we can
>> use a constructor with the list of attributes as a parameter.
>> - For attributes, we have the same problem : we may have more than one
>> value.
>> DO any of you guys have a strong opinion ?
> Entry and Attribute object created by the user of the API shouldn't be
> immutable. As user of the API I want to create an Entry object and add
> attribute and values to it. So the API must provide setters.
> So I think if Entry and Attribute are interfaces we just define the
> getter methods.
> The default implementations of those classes (e.g. ClientEntry and
> ClientAttribute) additional have setters the user can use when
> constructing the objects.
> The Entry objects returned from the API (e.g. from a search) should be
> immutable to protect them from being casted by the user, e.g. by
> wrapping a created ClientEntry into an ImmutableEntry implementation.

I agree with Stefan.

Alex Karasulu
My Blog ::
Apache Directory Server ::
Apache MINA ::

View raw message