Generic collections - relegate to an appendix?

(I tweeted a brief version of this suggestion and the results have been overwhelmingly positive so far, but I thought it would be worth fleshing out anyway.)

I'm currently editing chapter 3 of C# in Depth. In the first edition, it's nearly 48 pages long - the longest in the book, and longer than I want it to be.

One of the sections in there (only 6 pages, admittedly) is a description of various .NET 2.0 collections. However, it's mostly comparing them with the nongeneric collections from .NET 1.0, which probably isn't relevant any more. I suspect my readership has now moved on from "I only know C# 1" to "I've used C# 2 and I'm reasonably familiar with the framework, but I want to know the details of the language."

I propose moving the collections into an appendix. This will mean:

  • I'll cover all versions of .NET, not just 2.0
  • It will all be done in a fairly summary form, like the current appendix. (An appendix doesn't need as much of a narrative structure as a main chapter, IMO.)
  • I'll cover the interfaces as well as the classes - possibly even with pictures (type hierarchies)!
  • Chapter 3 can be a bit slimmer (although I've been adding a little bit here and there, so I'm not going to save a massive amount)
  • It will be easier to find as a quick reference (and I'll write it in a way which makes it easy to use as a reference too, hopefully)
  • I don't have to edit it right now :)

Does this sound like a plan? I don't know why I didn't think of it before, but I think it's the right move. In particular, it's in-keeping with the LINQ operator coverage in the existing appendix.

Published Fri, Oct 2 2009 22:00 by skeet
Filed under: ,

Comments

# re: Generic collections - relegate to an appendix?

If it is already a long PDF/book, why do that for 6 pages? I vote for keeping it in-chapter

:)

- Joe, the voice of .Net/C# newbies..

Friday, October 02, 2009 4:15 PM by Joe Hendricks

# re: Generic collections - relegate to an appendix?

Sounds good to me. Assuming a basic knowledge of C# 2 makes sense for this edition.

Friday, October 02, 2009 4:21 PM by Mark Heath

# re: Generic collections - relegate to an appendix?

Maybe slim it down do just a few sentences about Generic vs. Non-Generic collections (For example, ArrayList is still used a bit too often in my opinion, but there seem to be reasons where it is appropriate). Other than than, a short overview should be enough. What about stuff like SortedList vs. SortedDictionary? (don't have c# in depth here at the moment to check)

Friday, October 02, 2009 4:24 PM by Michael Stum

# re: Generic collections - relegate to an appendix?

@Joe: It's not really a book suitable for newbies to start with. It's really aimed at folks with C# 1 experience who want to delve deeply into C# 2-4.

@Michael: I go into SortedList/Dictionary in the first edition, and I'd certainly include them in the appendix with a brief description - and in particular the performance characteristics... but possibly not quite so many of the little nooks and crannies.

Friday, October 02, 2009 4:27 PM by skeet

# Generic collections - relegate to an appendix?

DotNetBurner - burning hot .net content

Friday, October 02, 2009 6:15 PM by DotNetBurner - C#

# re: Generic collections - relegate to an appendix?

For what it's worth I like this idea a lot as it is very self-contained and could be a great reference for folks who are just learning about generic collections.  

I would also hope that you would include some advice about when each type is appropriate.  Something like a table that says "Use IEnumerable<T> when..." and "Use List<T> when...".

Friday, October 02, 2009 7:20 PM by Andrew Hare

# re: Generic collections - relegate to an appendix?

IMNSHO, the only reasons to even bring up .NET 1.0 Collections (i.e. non-generic) is:

1. To explain why it is an abomination to write new code that uses non-generic collections.

2. To explain how to convert to and from non-generic collections to interact with legacy code. i.e. IEnumerable.Cast<T> and such.

3. A brief table showing the mapping from non-generic to generic (in an appendix).

3. And a repeat of #1. Maybe more strongly worded than #1.

I like the idea of an appendix if it will provide some additional insights beyond what I find on MSDN.

But I could really do without the .NET 1.0 reference material because too many people seem to think it's ok to use them all the tiem. Any sort of acknowledgement of their existance seems to all the justification these sadists need to keep using non-generic collections.

The discussion on interfaces and the general concept of an interface driven object model would be a good discussion. It may even be worth keeping in-chapter as a lot of intermediate developers I've run into don't truly grok why all of those interfaces exist.

The rule I use for the rookies: "Every time you use non-generic collections, the terrorists win. Do you hate America?"

Jon--I'll let you steal my line for free, no credit necessary. Just send me an autographed copy. :-)

Friday, October 02, 2009 9:12 PM by James Schek

# re: Generic collections - relegate to an appendix?

Starting with C# 2 makes sense, and I don't think anyone needs to read about non-generic collection classes in great detail anymore.

Saturday, October 03, 2009 2:31 AM by Chris Nahr

# re: Generic collections - relegate to an appendix?

Yes .. it should go in the appendix. At this point, you've got to assume CSharp 2. I'd bet MS would like to deprecate the non-generic collections if they could.

Saturday, October 03, 2009 5:40 AM by keithflo

# re: Generic collections - relegate to an appendix?

I never read appendices. I like books for their sequential layouts and narrative style (otherwise I'd only read online references) so jumping down to read an appendix breaks the flow. Once I'm done with the book reading appendix outside of any context does not make sense either.

Saturday, October 03, 2009 7:58 AM by zvolkov

# re: Generic collections - relegate to an appendix?

I like the appendix idea.

Saturday, October 03, 2009 9:17 PM by Bill Sorensen

# re: Generic collections - relegate to an appendix?

Event if I don't like appendices too much, I love the idea of having a part of the book describing collections.

Monday, October 05, 2009 3:24 AM by Philippe

# re: Generic collections - relegate to an appendix?

I agree - move it to an appendix.

It's useful information to retain for those who are not familiar with generic collections or who want a quite lookup to check how they stack up against v1 - but the vast majority are really going to be c#2+ programmers.

Tuesday, October 06, 2009 3:47 AM by Matt Chatterley

# re: Generic collections - relegate to an appendix?

Sounds good to me.

Tuesday, October 06, 2009 5:19 AM by Franck Jeannin

# re: Generic collections - relegate to an appendix?

Go for it

Saturday, October 17, 2009 7:53 PM by Yonah Wahrhaftig

# re: Generic collections - relegate to an appendix?

I would recommend to move to an appendix for following reasons.

1. A reader can jump at any point in time to seek reference.

2. It can be stand like a design lesson for a fresh developer stating why & which things are changed?

Monday, October 19, 2009 11:53 AM by Manish Patil