Simulated Covariance for .NET Generics

I just wrote this pattern, but I am not sure if I should add it officially to the Framework Design Guidelines. It seems like a bit of a corner case scenario, though I do get questions about it from time to time. Anyway, let me know what you think.    Different constructed types don’t have a common root type….

20

Synchronization at the Right Level

I get a lot of questions about why the new generic collection interfaces (IList<T> for example) do not support synchronization. There are several reasons for it. One, probably the main, is that in practice synchronizing on the level of a single data structure is rarely useful. Rico explains this in a series of posts on…

2

C5 Collections

Peter Sestoft and his team just released a library of collections for the CLI called C5 Collections. Unlike the Power Collections, this library introduces many new abstractions that are not present in the .NET Framework. The benefit of such approach is that it allows for some powerful scenarios that are not possible if you simply build…

5

Disposable Collection

Somebody asked me today, if we have a collection that is disposable and calls dispose on all its items when the collections.Dispose method is called. You can implement such collection by inheriting from List<T> and adding Dispose logic. If you add one additional requirement that Dispose is called on the items before they are removed…

12

Immutable Collections

I just saw an interesting post that talks about a general pattern of immutable reference types. Good read. I highly recommend it! At the end of the post the author suggests that we add “value object” generic collection to the BCL. It’s an interesting suggestion, but unfortunately not as easy as it may seem. The…

4

Why we don’t recommend using List<T> in public APIs

We don’t recommend using List<T> in public APIs for two reasons. List<T> is not designed to be extended. i.e. you cannot override any members. This for example means that an object returning List<T> from a property won’t be able to get notified when the collection is modified. Collection<T> lets you overrides SetItem protected member to…

30

System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel

Many people ask how the new.NET Framework 2.0 generic collections relate to the non-generic collections we shipped before. So, here you go. The most important types are in bold font. List<T> is basically a better ArrayList. It is optimized for speed, size, and power. Use it for majority of internal implementations whenever you need to…

24

List<T> vs. ArrayList Performance

Rico just posted a new performance quiz where he compares performance of List<T> and ArrayList in some simple scenarios. List<T> is my Whidbey baby, so of course I had to answer that List<T> is faster 🙂

0

PowerCollections Beta Avaliable

The beta release of the PowerCollections library has been posted today. See http://wintellect.com/WEBLOGS/pgolde/archive/2005/06/03/1304.aspx.  

1

Generic interfaces, IsReadOnly, IsFixedSize, and array

Peter Golde recently posted about the IsReadOnly and IsFixedSize change we made to the generic collection interfaces.There are also several other discussions around the net on this topic. I thought I write up something to explain the motivation and our thinking on this. We decided that there are really not that many fixed size data…

10