Saturday, October 30, 2010

Book Review: C# 4.0 in a Nutshell

A few weeks ago, I finished reading C# 4.0 in a Nutshell: The Definitive Reference by Joseph Albahari & Ben Albahari.  I'll start off by saying this is an extremely large "nutshell" (the index starts on page 997), and I spent several months reading it in small pieces.  The good news is that it was extremely worthwhile.

I had not read a book dedicated to C# since .NET 1.0 came out.  And that was simply to get to know the language.  Through the years, I've read numerous .NET books, but mostly focused on a particular technology, not on the C# language itself.  So, this was a good chance for me to read up on the language from beginning to end.  This helped refresh things that I had learned long ago and forgotten, as well as fill me in on the pieces that I missed over the years, and finally including all of the new features that we got with C# 4.0 including dynamic types, code contracts, and the parallel library.

In the preface, the book itself describes what it is not.  It is not a replacement for IntelliSense or on-line help; meaning, it does not have a complete listing of all members of each class.  Instead, it gives a good overview of select classes and the primary members that you need to know to utilize those classes.  Also, it is not a beginner book or a replacement for tutorials that introduce a new programmer to specific topics.

With that said, I found the book extremely useful.  The chapters are well laid-out, and I have found it easy to go back and use this as a reference book for particular topics when needed.  Here's a list of the chapters:
  1. Introducing C# and the .NET Framework
  2. C# Language Basics
  3. Creating Types in C#
  4. Advanced C#
  5. Framework Overview
  6. Framework Fundamentals
  7. Collections
  8. LINQ Queries
  9. LINQ Operators
  10. LINQ to XML
  11. Other XML Technologies
  12. Disposal and Garbage Collection
  13. Diagnostics and Code Contracts
  14. Streams and I/O
  15. Networking
  16. Serialization
  17. Assemblies
  18. Reflection and Metadata
  19. Dynamic Programming
  20. Security
  21. Threading
  22. Parallel Programming
  23. Asynchronous Methods
  24. Application Domains
  25. Native and COM Interoperability
  26. Regular Expressions
As you can see, there are quite a few chapters that cover pretty much every part of the C# language (as well as parts of the .NET framework itself).  I really can't go into details on each of the topics.

One thing that is nice about this book that makes it a complete reference is that it covers parts of the language even if they are no longer the recommended techniques.  For example, there is a complete chapter on LINQ to XML.  For those of you who have not yet tried LINQ to XML, take a look at it.  After trying it, you will never go back to the "old" way of parsing and creating XML documents.  With that said, the book also has a chapter on "other" XML technologies.  This is important because even if you are not creating new code using these technologies, you may experience existing code that uses them.

There are a number of advanced topics, which further complements the "not a beginner book" statement in the preface.  These include things like reflection, the insides of building, signing and deploying assemblies, the security model (such as trusted callers and encryption), and the ins and outs of threading.

The new features in C# 4.0 are covered as well.  This includes a full chapter on the parallel library.  There were some interesting points that were made here including showing how the order that things happen in the parallel processes is indeterminate.  Also, there is a discussion of the various ways of "partitioning" -- helping the parallel library know how to best split up the tasks.  (Of course, you can also let the framework take it's best shot at splitting up the tasks, and this will work most of the time.)

Overall, this was an excellent (if extremely long) read.  For me, I was reminded of some of the fundamentals of the C# language, I picked up a few tips on things I didn't know existed, and I also learned about the new pieces that were added to the 4.0 version of the language.

I'll recommend this book to intermediate level .NET programmers or experienced programmers who are new to C#.  I'll keep this as a reference on my shelf and refer to it frequently.

Happy Coding!

Monday, October 25, 2010

Thanks for Coming - SoCal Code Camp Los Angeles

Thank you to everyone who came to my sessions at the SoCal Code Camp this last weekend.  And a special thank you to all of you who came to more than one of my sessions.  I had a great time doing the presentations and meeting all of you.  I hope that you found it worthwhile.  As a reminder, the slides, code samples and walkthroughs are available on my website:

I've collected a number of questions that came up and will have answers posted here in the near future.  A couple questions even came up in both the Saturday and Sunday sessions, so those will go to the top of the list.

Still coming, I also have  a book review for C# 4.0 in a Nutshell by Albahari & Albahari.  Short version: excellent book in a gigantic nutshell (over 1,000 pages).  I've been a little delayed in getting the review out with my preparation for Code Camp (plus, I started a new job this week).  I've started reading my next book: Pro ASP.NET MVC 2 Framework by Steven Sanderson.  This has been a great read so far and will most likely end up on my "recommended" list.

In the meantime...

Happy Coding!