Freigeben über


What things do you most miss from the BCL?

The BCL (still) not including a Set<T> class is among my highest pet peeves - it's a constant top 10 on product feedback.  That Java's had it since Dec 1998 when Playground shipped with the Collections framework just makes things worse, arguably.

One of the other classes I miss (like Set, easy to make by hand, just annoying that it's not in the BCL) is LinkedHashMap which let you iterate over the keys in a hash in insertion order.  To a much lesser extent, I kind of miss BitSet and WeakHashMap but those aren't as big of a deal to me.  There are places where LinkedHashMap would be nice because you can't (for instance) serialize a hash because you're not sure what the right ordering is for the key/value pairs.  Having a LinkedHashMap would fix this, since there's now an ordering associated with the hash.

Which classes/features do you miss?  They don't have to be collections necessarily (and make to check out Power Collections if you want some very powerful collections in your .NET 2.0 development), but anything that you feel really should be in the BCL.  If you get a chance, after you add a comment here, go ahead and make sure your entry is represented (add it if not) and voted for @ the product feedback center! :)

To be fair, there are things I really love about the BCL (and to an extent, the CLR's implementation and the C# compiler).  A few:

  1. "real" generics (not just added compile-time type checkin) - a List<int> or Stack<int> isn't storing boxed objects. (check Anders' comments for details)
  2. IEnumerable<T> is a wonderful thing.  Once you've had a problem where it's the right fit and you do a method with yield return, you'll wonder how you lived without it (think before and after owning your TiVo, for instance).
  3. IDisposable and using - while the particular pattern is still up for debate, and it's not brain-dead simple just yet, it's at least useful syntax sugar over try/finally's everywhere.  Check out Andy's related blog entry for some background.
  4. enums
  5. String's overloads with StringComparison enum.  This will cause religious wars and people will have love/hate relationships with these overrides, but I like the explicit-ness of it.  String handling is something that's notoriously easy to write code that's simple, efficient, and wrong.
  6. SafeHandles - These are a great approach to encapsulating your unmanaged resources.  It makes your development life a lot easier in my experience, and I'm looking forward to seeing how they're used by developers.
  7. BindingList<T> - data binding is already very cool, but BindingList<T> makes it so much simpler to make a custom object and have it bound to a DataGridView.  Very useful stuff.
  8. BackgroundWorker - It's a great way of doing stuff on background threads.  I already love that the CLR has its own threadpool (that the JVM didn't have one always surprised me), and now it's that much easier to use in a simple, easy-to-understand way (which arguably BeginInvoke and IAsyncResult was not)

And other 2.0 features in general:

  1. MSBuild - Yeah, the claims of "Ant rip-off" will be a-plenty, but having it as the file format for VS projects helps unify the worlds and makes it much easier on developers IMHO.
  2. ClickOnce - I haven't had a chance to really kick the tires yet, but from my Java WebStart days, it looks like a really slick implementation and I have a lot of hope for it.
  3. ASP.NET 2.0 - plentiful new features - it's very slick.
  4. All the entries in the System.Net.NetworkInformation namespace, like the NetworkInterface class.

Comments

  • Anonymous
    June 29, 2005
    Features missing:

    0) Some kind of ordered collection with logarithmic complexity providing set and multiset operations (union, intersection, subtraction, merge). I had to write 3 of these already, and I've only been using .NET for 18 months.

    Unfortunately, Power Collections has an offensive requirement in its license: it cannot be used in a project which uses free software of any kind. The Power Collections license restricts the future options on any project which uses it. I'd strongly recommend steering well clear of Power Collections for that reason.

    1) Proper DB-independant class support. Currently there's far too much stuff that's SQL Server specific in .NET's DB libraries. Getting the parameter types for a stored procedure once only, then reusing them, for example.

    2) WinForms could be hugely improved in performance and features. Currently, complex forms with nested UserControl descendants and controls using Anchor and Dock properties for positioning take an age to resize and redraw.

    Examining profiling stack traces for resize and redraw on WinForms reveals call chains >200 levels deep for a simple resize. Absolutely ludicrous.

    Some kind of command architecture which can be linked to UI elements, along the lines of TActionList and TActionManager in Delphi's VCL, would be a huge improvement.

    3) Some way of cheaply checking that an enum variable value is in the valid range of the enum that isn't accompanied by the usual "THIS USES REFLECTION AND IS VERY SLOW SO DON'T USE" disclaimer.
  • Anonymous
    June 12, 2007
    Since it's coming up on 2 years since I complained that the BCL didn't have Set&lt;T&gt; I figured I