|
From: Frank V. C. <fr...@co...> - 2000-01-11 01:22:53
|
>> 2. Is corelinux based on templates? >> I read the blurb on the use of templates. Static type checking is a really >> nice feature to have. Yet, if you look at a language like java, where all >> classes inherit from a superclass Object, non static type checking has its >> benefits.. Ie. the ability to stick almost anything in a hashtable. I see >> how this could be resolved using templates and a strict java-like class >> heirarchy.. > The lack of genericity is a weakness of Java, not a strength. Sticking > all kinds of things into a hashtable is a hack and causes all kinds of > nightmares. First of all, why would you want to stick lots of unrelated > data into a hashtable? That would certainly reflect a poor design > decision somewhere in your code. But if the data are related to each > other, why aren`t they in a class together? If they`re in a class, you > can store a collection of these classes with templates, thus preserving > type safety and more clearly showing yourself and others your coding > intentions. > > --Joe My $.02 A Bag is an unordered collection of objects that may be repeated and don't have to be related. In Java, all objects ARE related through the Object super class EXCEPT scalars and boolean (although this is solved through the wrappers). The hashtable won't allow repeats and all objects are related. I agree that a hashtable is NOT a bag. For C++ in problem domains like Shopping Carts or Solar Systems bags MAY be desired and I would think there is some kind of taxonomy that the members belong to (M class planets, produce, etc.). The limitation is that unless you use a void pointer as the element you are constrained by the template definition type. -- Frank V. Castellucci http://corelinux.sourceforge.net OOA/OOD/C++ Standards and Guidelines for Linux |