Author: Jon Skeet
Audience: Intermediate C# programmer who wants to master the language
Reviewed by: Sue gee
What does the third edition of this authoritative and highly rated book on C# contribute?
The dilemma facing an author updating a book to cover a new version of a programming language is whether to rewrite the entire work to reflect the new emphasis in the language, or to patch in new material.
Of course this partly depends on how revolutionary the update in the language is and in the case of C# going from 4.0 to 5.0 the new features didn't disturb the existing ones;
To quote Jon Skeet:
It's simple to describe C# 5: it has exactly one big feature (asynchronous functions) and two tiny ones.
The approach Jon Skeet has taken in producing the third edition of his book on C# is to add an extra part covering C# 5.0. And if you look at the titles given to the Parts you'll see that this is logical:
Part 1 Preparing for the Journey
Part 2 C#2: Solving the Issues of C#1
Part 3 C#3: Revolutionizing Data Access
Part 4 C#4: Playing Nicely with Others
Part 5 C#5: Asynchrony Made Simple
Given this outline you might assume that the first part of the book covers C# 1 but that's not the case.
As Jon Skeet explains on page xxiv:
"This is a book about C# from version 2.0 onward - it's as simple as that. I barely cover C#1 and only cover the .NET Frameworrk libraries and the Common Language Runtime (CLR) where they're related to the language."
He also points out that: "The book is squarely aimed at developers who know some C#" and this seems fair enough for a book that has "In Depth" in the title.
In his review of C# in Depth, 2nd Ed, in which he awards it the highest possible rating of 5, Nikos Vaggalis explains the structure of the book and its effect on the reader:
The book does not serve as an introduction to C#, rather it goes through its evolution zooming into its milestones; the important properties that give the language character such as delegates, generics, lambda expressions, extension methods and more.
From C# 1 to C# 4, each versions' newly introduced features are examined, and the already existing ones are compared with their newest counterparts. For example, keeping a close look on the ever changing face of delegates from a type declaration in C# 1 to the lambda expressions in C# 4.
This comparison approach serves as a mediator to understanding the new syntax, or rather the shortcuts or syntactic sugar, but it also has a deeper purpose. It makes the concepts behind the issues that forced change to occur and drive C# 1 to evolve, much easier to understand.
Given this incremental approach the first four parts of the new edition of the book are largely unchanged. There is an extra section in the first chapter which presents an overview of the evolution of C#. Occupying a page and a half and with the title Writing asynchronous code without the heartache it previews the big feature of C# 5 which is the main topic of the new Part 5. After this everything we have essentially the same material as in C# in Depth, 2nd Ed until we hit Chapter 15.
So if you are interested in the contents of Chapters 1 through 14 of the current book refer to the earlier review. Here we'll add a review of Part 5 which has two chapters replacing the previous Chapters 15 and 16.
Before looking at the new material its worth asking why Jon Skeet dropped the existing Chapter 15, which was on Code Contracts. One reason is that it is a topic that isn't specific to C# and another might simply be that the idea didn't take off in the way Jon Skeet anticipated it might. He begins the very last section of the final chapter, Closing thoughts by saying:
The first two editions of C# is Depth closed with a chapter dedicated to the future as I perceived it at the time of writing. If you own either (or both!) of those editions you may want to look back and have a quiet chuckle to yourself. I don't think I said anything outrageously wrong. but I clearly had little idea of how much things could change in just a couple of years.
Jon Skeet brings his enthusiasm about C#, noted by Nikos Vaggalis in his review to the new content. At 56 pages Chapter 15: Asynchrony with asyc/await is the longest in the book. Opening it with the statement:
"Asynchrony has been a thorn in the side of developers for years"
Skeet goes on to proclaim in a prominent box out:
Async/Await will rock your world.
and quickly moves on to demonstrating the use of the new asynchronous functions with a simple example. In the course of the chapter he covers the aims of ansynchrony and how to write async methods and delegates and compiler transformations for async. While he goes into the topic in depth, he uses plenty of code to illustrate the ideas, all of which is fully explained.
Chapter 16 is devoted to the two minor new features in C#. He notes that the first of them - changes to captured variables in foreach loops - is in fact a correction to a earlier mistake in the language's design. Having covered it in less than a page, including a helpful example, we move on to caller information attributes, a feature which Skeet describes as "extremely targeted" before providing a succinct overview with three code snippets.
So if you already have a copy of C# In Depth on your shelves should you buy a copy of the new version. The answer has to be yes if you want to understand the big new feature of C# 5.
But if you don't already have Jon Skeet's book and have progressed beyond being a beginner with C#, this is a book that should be added to your shelf. Highly recommended.
For more good books on C# see C# Books - Pick of the Shelf