S
SpookyET
I've been wondering about some of the decisions that were made about the
..net framework:
- Why are arrays not dynamic, where you can decrease/increase the size of
the array without creating a new one, then copy the values from the old
one into the new one, and destroying the old one, which is what ArrayList
does. This will kill the need for a Linked-List (which currently is not
in the System.Collections name-space). Sometimes you may care more about
the amount of memory used than the speed of allocating a new node in the
list. Also, a linked list does not have the problem of array
fragmentation, which happens when you remove items from the middle of the
array.
- Why are strings immutable? Why not have String and StringBuilder united
in one class under the name String?
- Why weren't generics available in the v1.0 of the framework? It is very
annoying to have to create your own collections because you don't want to
slow your application down because of type casting to and from object.
When you want a collection that accepts any type, it makes sense to use
the base class of all objects, but most of the time you want a collection
of only one type of objects. You have CollectionBase for strongly typed
collections, but that still is using casting to and from object.
That is it for now. I've been using C# since 2002, yet I have had this
questions on the back of me mind for a long time.
..net framework:
- Why are arrays not dynamic, where you can decrease/increase the size of
the array without creating a new one, then copy the values from the old
one into the new one, and destroying the old one, which is what ArrayList
does. This will kill the need for a Linked-List (which currently is not
in the System.Collections name-space). Sometimes you may care more about
the amount of memory used than the speed of allocating a new node in the
list. Also, a linked list does not have the problem of array
fragmentation, which happens when you remove items from the middle of the
array.
- Why are strings immutable? Why not have String and StringBuilder united
in one class under the name String?
- Why weren't generics available in the v1.0 of the framework? It is very
annoying to have to create your own collections because you don't want to
slow your application down because of type casting to and from object.
When you want a collection that accepts any type, it makes sense to use
the base class of all objects, but most of the time you want a collection
of only one type of objects. You have CollectionBase for strongly typed
collections, but that still is using casting to and from object.
That is it for now. I've been using C# since 2002, yet I have had this
questions on the back of me mind for a long time.