(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.
15 thoughts on “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..
Sounds good to me. Assuming a basic knowledge of C# 2 makes sense for this edition.
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)
@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.
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 when…” and “Use List when…”.
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 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. :-)
Starting with C# 2 makes sense, and I don’t think anyone needs to read about non-generic collection classes in great detail anymore.
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.
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.
I like the appendix idea.
Event if I don’t like appendices too much, I love the idea of having a part of the book describing collections.
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.
Sounds good to me.
Go for it
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?