X_AWieminer_X wrote:
> >>Current core Properties class is extended from Hashtable. Hastable is a
> >>synchronized keyvalue container from Java1 era.
> >>
> >>Do you see here any use of "Properties2 extends Hashmap" implementation.
> >>What pros and/or cons. Should Java2 has a properties-like class using Java2
> >>collection implementation?
> >
> > It should have an implementation of Properties which doesn't implement
> > Map at all. Making Properties extend Hashtable was a mistake to start
> > with.
>
> Hmm..interesting. Would you share your thoughts more in detail. Im
> planning to create own namevalue class for taylored use.
I can't speak for Jon, but I can explain why I think it was a mistake to
have Properties extend Hashtable. It's because a Hashtable is a more
general-purpose kind of data structure that's suitable in more places
than a Properties. For example, Properties requires that names and
values be Strings, whereas with Hashtable they can be any Object.
However, because Properties extends Hashtable, you can get around that
requirement with a back door that allows the user to break the general
contract of the Properties class.
Even if that were fixed (for example, by overriding the Hashtable put
and get methods to throw exceptions if the arguments aren't Strings), a
Properties object would still be useful only in a limited set of
circumstances compared to a Hashtable... which violates the general
principle of substitutability (sometimes called Liskov substitutability,
after someone who stated it clearly). That means that you could
conceivable have a reference of type Hashtable (which points to a
Properties object), and it would be inherently broken to give it to a
method that is supposed to operate on all Hashtable objects.
My guess is that this design decision was made by someone who was still
stuck in the "fascinated-by-inheritance" phase of OO understanding.
> What I dont like most with current Properties is .load/.save methods not
> supporting UTF-8 format. Its quite hard to write config files with Win2k
> Notepad 'cause unicodes should use \uXXXX escaped format.
Which, of course, has little to do with its being derived from
Hashtable.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation