Thursday, 3 April 2008

Book Review: Pro LINQ

Pro LINQ: Language Integrated Query in C#2008 by Joseph C. Rattz, Jr. Rating: 3 out of 5.

I ordered a copy of Pro LINQ just before Christmas for a colleague who needed to get up to speed with C#3.0 for our most recent project. I got my hands on it a little while back, and thought it would make for a topical first book review for the blog.

Pro Linq aims to cover all the new Language Integrated Query features that have been introduced into .Net 3.5, from a C# perspective. After a brief chapter painting a picture of the new LINQ landscape, it kicks off with an introduction to the new language features in C# 3.0. Then follow sections on LINQ to Objects, LINQ to XML, the oft-forgotten LINQ to DataSet, concluding with LINQ to SQL. It would have been interesting to hear about LINQ to Entities, but the author, reasonably enough, declared that outside the scope of his book.

The author declares that his book "is all about code". And in fact it is organised around code. Most of each section is organised around the methods and properties of the LINQ classes.

What I liked

On the whole I found Pro LINQ easy to read. The author has a conversational style, and gives reasonably clear explanations.

There's a thorough, exhaustive (though some might say exhausting!) reference of all the new LINQ APIs in every area mentioned above.

The most useful section for me was the one covering LINQ to SQL. After covering all the basics, it goes into some detail about the harder aspects like handling concurrency conflicts.

Right at the beginning of the book, the author has included a "Tips to Get you started" section listing common pitfalls.

What I didn't like

Given that LINQ is so revolutionary, I finished the book feeling rather uninspired, despite my own enthusiasm for the subject. I think this was partly the fault of the examples used. I can appreciate that it must be very hard to create something fresh for everything you want to illustrate, but I felt the author could have come up with something more imaginative than filtering a list of US Presidents, for example.

What I would have liked to have seen were examples of the different parts of LINQ working together. Most of the samples dealt with just one concept at a time (which I know is how it needs to be to get started) but the excitement comes from putting everything together, and we never really got to that point.

There was also a lot of repetitiveness. This book has an example for almost every overload of every Enumerable class extension method, and not much variation in the examples either. And do we really need the console output of every code sample? These things made a lot of the book read like MSDN. The fact that under every method, the author had listed Exceptions that might be thrown by the method just added to the feeling that I might be better off reading through the online help.

Don't expect either to find in this book much about deeper considerations: when to use LINQ, or when to avoid it; how well the LINQ APIs perform, or indeed how they work; or anything about the bigger picture of Functional Programming is. This book doesn't get much beyond the limited picture of what the LINQ APIs are, and how to call them.


I'm afraid the last few paragraphs sound negative: that's because I had high hopes for this book, but came away dissapointed. It is certainly useful, and I'll pass it around the office for people getting started, but I expect that I'll find a replacement before long. Hopefully one that talks more about the why and the when, not just the what and the how.


Post a Comment