|Developer's Guide to Collections in Microsoft .NET|
Author: Calvin "Lee" Janes
Author: Calvin "Lee" Janes
I know that many a skilled programmer finds the .NET collections libraries difficult to cope with. Part of the problem is theoretical - when to use a dictionary rather than a list - but some of the confusion is caused by the different versions of the collection classes that are available. So a book on the Collection Classes seems like a really good idea. However, what you make of this particular take on the subject depends very much on what you are looking for and on how tolerant you are of diversions.
The first part of the book, approximately 110 pages, provides a practical course in collections. You are shown how to build your own collection classes - arrays, linked lists, associative arrays, queues, stacks and buffers. The code is given in both VB and C#. There is a reasonable explanation of the theory behind each data structure and a discussion of how best to implement it but you do need to know that most of the pages are taken up with heavily commented code.
If you are interested in how collections work, or if you missed out on the theory, then this might be of use to you, but it doesn't get you to understand the .NET collections classes. An alternative approach to Part I of the book would be to explain the theory and then illustrate the ideas using the collection classes; this would at least get you deeper into the specifically .NET material.
Part II of the book does at last focus on the collections classes. Chapter 4 delves into the Generic collections, which for many programmers are the hardest to use, perhaps because they don't make much use of generics in their programming. The chapter begins with some theory, but not of how generics are used. Instead we get an overview of ordering, delegates, anonymous methods and lambda expressions. Then we look at the List(T) class and the book gets back to being code-heavy very quickly as it illustrates how to do all of the standard operations - sorting, searching and so on. This sets the pattern for the following data types. We go over LinkedList(T) at the end of the chapter and then on to Queue(T), Stack(T), Dictionary(T), BitArray, CollectionBase, DictionaryBase, HashSet(T) and SortedList in Chapter 5. This part of the book can be best described as reference documentation with examples.
Part III is all about using collections, which sounds like a great idea, but some of the topics could just as well have been in Part II. For example, adding enumerators isn't really an advanced topic. Chapter 7 explains the basics of Linq, which is a technology that both makes heavy use of collections and makes collections easier to use. Chapter 8 tackles the difficult topic of using threads with collections. This is perhaps the most advanced and most useful of all of the chapters. Given how important multi-threading is becoming any help on how to use supplied classes is welcome. Chapter 9 brings the section to a close with information about serializing collections.
Part IV starts to look a little wider in the rest of .NET and specifically the UI. Using collections with controls is all about databinding. Chapter 10 looks at the general principles of databinding and Windows Forms and Chapter 11 takes a quick look at how WPF and Silverlight are different.
This is a book that is very heavy on code. Before you raise a cheer you need to remember that the code is given in both C# and VB and so there is a lot of redundancy. In addition the code is given in long chunks usually, but not always, with lots of comments. As to the topics covered, they are mostly just examples of the sorts of things you can find in the documentation and the book rarely goes off the beaten track. In particular, it doesn't cover the relationships between the collections and the more recent innovations just as PLinq, TPL, and Rx.
Overall I found the book difficult to read for reasons that aren't entirely easy to work out. It was hard work reading the code and if you skipped the code it was difficult to discover where to read next. Although there are some reasonably good explanations they are mostly buried under a lot of fairly obvious and duplicated code. If this is the sort of book you like then you might get something out of it. For me the book sat between being too difficult an introduction and too simple an advanced work.
|Last Updated ( Monday, 09 January 2012 )|