Mombu the Programming Forum

Mombu the Programming Forum > Programming > Properties2 extends Hashmap, pros and cons?
REGISTER NOW! Search Today's Posts Mark Forums Read




Reply
 
Thread Tools Search this Thread Display Modes
1 14th April 11:23
xarax
External User
 
Posts: 1
Default Properties2 extends Hashmap, pros and cons?



/snip/

You're probably exactly right about that. The implementor saw
some apparent similarities and decided to reuse the code. A better
approach would have been to design an interface for Properties
and an abstract implementation AbstractProperties that internally
used a Hashtable object (thus getting the code reusability he
wanted in the first place). A factory class would dispense
objects that implement the Properties interface that would
protect client code from becoming dependent upon the actual
implementation details.

Other languages, like Eiffel, would allow a private inheritance
of a Hashtable implementation so that client code could not
up-cast the object and use it like a Hashtable. However, that's
not the case for Java, so object composition would have been
a better choice than inheritance.
  Reply With Quote
SPONSORED LINKS BY GOOGLE

 


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes







Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
Also visit Ogoun the Usenet Archive
666