Saturday, July 10, 2004

Re: Unified Type System

I was saying because there is a hierarchy with Object being the root, the Collection classes can work with just Objects and not have to worry about other classes. Now, if they had introduced the framework with generics, you could have just done ArrayList, ArrayList, ArrayList and they would NOT need to inherit from Object. This is how it is in C++.

I'll repeat what I think you meant. Collections store pointers of type Object which can be later Cast into various Types. If this is what you meant, yipee for understanding and I see your point.

Generics in C++ essentially auto-generate the classes based on type?

What do you think happens in Java/.NET Generics? I suppose they 'fortified' the current Collections by forcing Type. This reduces Casting troubles at run-time and also provides better perf. So I think Generics are as dependent on Object.


I don't see this as an advantage

You seem to have agreed with the importance of the other methods. toString( ), clone( ) and equals( ) are not the most important, but are pretty useful in many cases. Placing them in Object must have been thought over.

No comments: