|
From: Thomas M. <t.r...@wo...> - 2000-01-12 02:34:02
|
----- Original Message ----- From: Frank V. Castellucci <fr...@co...> To: CoreLinux mailing list <cor...@li...> Sent: Monday, January 10, 2000 8:26 PM Subject: RE: [Corelinux-public] a few questions > > >> 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.. Actually all collections in both Java and C++ are homogeneous. They don't let you "stick almost anything in them" they only allow to stick one thing in them, in your example everything would have to be an Object. The fact that everything in Java is derived from Object is of little or no help because you must cast the Object to its derivation to do anything meaningful. Typically this is really ugly type checking code that is the hallmark of poor or shortsighted analysis. Tom > > > 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 > > _______________________________________________ > Corelinux-public mailing list > Cor...@li... > http://lists.sourceforge.net/mailman/listinfo/corelinux-public > |