|
Re: need help for subclassing Collections Framework classes
|
Posted: Jun 10, 2005 12:54 AM
|
|
> Can we extend the classes which are members of the > Collection Framework.
yes, you can extend classes which are members of the collection framework like hashmap, vector etc.
>If so when is it required to do such things .
Collection classes are too raw data types. In problem space suppose you model, for example Cluster (that contains no.s od Nodes (hosts or m/cs). In this case you may have a class to model Cluster.
Now you may also have Node class, to model actual nodes.
Now Cluster should store all the nodes that are part of it?
So now we may make Cluster class extend from may be Vector class. And when administrator or user calls, add, remove, find etc over Cluster, it may call super class operations for the same.
> And lastly is it advisable to extend these classes ?
Just depends context of usage. Useful when your problem space exhibits those behaviour. And domain objects are never hastable, hashmap, vector etc.
So you need to judiciously make this decision.
regards, Shashank e-mail shashank@icmgworld.com
|
|