Subscribe via RSS

Book Review: Effective C#

Filed Under Book Reviews

Effective C#Although not his first book on C#, Bill Wagner really became noticed in the .NET community after writing Effective C#: 50 Specific Ways to Improve Your C#.

First off, this is not a C# reference guide. Instead, this is a collection of concrete arguments for using particular C# structures over their counterparts.

The greatest thing I appreciated is that Wagner shows cold, hard evidence for every tip. The cornerstone throughout the book is showing what occurs at compile time in C# and IL examples, and then continuing to explain what occurs at run-time. As an example, Item 11: Prefer foreach loops goes into great depth why the foreach loop is the more effiecient than do, while, and most hand-written for loops.

Perhaps the biggest performance tip I personally received came right away, Item 3: Prefer the is and as operators to casting. Which way would you rather write it?

object o = Factory.CreateInstance();
//Version 1:
MyType t = o as MyType;

if (t != null)
    return t.MyValue;

//Version 2:
if (o is MyType)
    return (o as MyType).MyValue;

//Version 3:
    MyType t = (MyType) o;

    if (t != null)
        return t.MyValue;
catch (Exception)
    //report a cast exception

Chapter List

  1. C# Language Elements
  2. .NET Resource Management
  3. Expressing Designs with C#
  4. Creating Binary Components
  5. Working with the Framework
  6. Miscellaneous

The Good

  • Quick & easy read
  • Solid rationale for every tip
  • Basic concepts still applicable after .NET 3.0
  • C# veterans and newbies can all learn something from this book

The Bad

  • Large number of typos
  • A few items are debatable (i.e. Item 41: Prefer DataSets to Custom Structures)
  • Does not encompass C# 2.0 or above
  • Last chapter titled Miscellaneous was weak. Should have been called 44 Ways To Improve Your C# + 6 Other Tips

I highly recommend this book as I learned a number of great tips that I still use today. It is a fun and quick read that anyone wanting to improve their C# will enjoy. With or without typos, I would give it a 4.

4 Stars Effective C#: 50 Specific Ways to Improve Your C#

Notice: All reviews on codesqueeze are not paid nor are traded for services. These reviews are shared so you may save time in your quest for better tools.

RSS Icon

  Don't miss a drop! Subscribe now via RSS or email.


Comments are closed.

Max Pool - © 2024 - {codesqueeze}. Sycorr Banking Solutions