Properties extends from HashTable - Sun's mess up
The basic idea of inheritance in the Object Oriented Paradigm is based on "is-a" kind of relationship. Any violation of this violates OO.
Its very interesting to note that, in Sun's java SDK, we have java.util.Properties extending from java.util.Hashtable. That actually sent me guessing.
If Properties was a class that will handle only string key-value pairs, what was the necessity to extend from Hashtable which supports key - Object pairs? I believe the ugly inheritance-composition confusion had forced one of Sun's engineers to make such a choice.
The store method of Properties tries to cast all values to String :P!
Properties doesnt even stop you from using Hashtables methods of put and get!
Well the actual way to have implemented properties must have been to use a Hashtable inside properties (Composition) and then expose whatever methods that you want to.
I am searching for other examples within the SDK where such a blunder still exists :)
No comments:
Post a Comment