Hi,

I was having a second look at the Value hierarchy, and I was wondering if some kind of refactoring would not be good.

Here is the current hierarchy :

Interface Value<T>
   Interface ClientValue<T> extends Value<T>
   Interface ServerValue<T> extends Value<T>

Class AbstractStringValue implements Value<String>
Class ClientStringValue extends AbstractStringValue implements ClientValue<String> Class ServerStringValue extends AbstractStringValue implements ServerValue<String>

Class AbstractBinaryValue implements Value<byte[]>
Class ClientBinaryValue extends AbstractBinaryValue implements ClientValue<byte[]> Class ServerBinaryValue extends AbstractBinaryValue implements ServerValue<byte[]>

Class AbstractStreamedValue implements Value<URI>
Class ClientStringValue extends AbstractStringValue implements ClientValue<URI> Class ServerStringValue extends AbstractStringValue implements ServerValue<URI>

I don't know why, but I find it heavy ;)

I was considering changing the hierarchy this way:

Interface Value<T>
   Interface ClientValue<T> extends Value<T>
       Interface ServerValue<T> extends ClientValue<T>

Class AbstractStringValue implements Value<String>
Class ClientStringValue extends AbstractStringValue implements ClientValue<String> Class ServerStringValue extends ClientStringValue implements ServerValue<String>

Class AbstractBinaryValue implements Value<byte[]>
Class ClientBinaryValue extends AbstractBinaryValue implements ClientValue<byte[]> Class ServerBinaryValue extends ClientBinaryValue implements ServerValue<byte[]>

Class AbstractStreamedValue implements Value<URI>
Class ClientStreamedValue extends AbstractStreamedValue implements ClientValue<URI> Class ServerStreamedValue extends ClientStreamedValue implements ServerValue<URI>

Not a big difference, but the big advantage would be that the code will be correctly handle in the correct level, avoiding some code duplication.

The idea is that the biggest difference between a ClientValue and a ServerValue is that the ServerValue can have its syntax checked (that means we store the AttributeType somewhere withing the ServerValue).

There are also other possibilities : The syntax checking can be done at the Attribute level, not at the level value :

Attribute.isValid( value, attributeType );

instead of :

ServerValue.isValid(); (assuming that the value contains the attributeType).

Last, not least, you can see that we have three classes handling 3 types (String, byte[] and URI). We could have used generics, but we found it better to avoid a lot of instanceof and cast all over the code.


Ok, now, tell me : do you have better ideas, advices, remarks ?
WDYT ?

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to