Effective C# (Covers C# 4.0): 50 Specific Ways to Improve Your C# (Effective Software Development Series) / Edition 2

Paperback (Print)
Used and New from Other Sellers
Used and New from Other Sellers
from $24.29
Usually ships in 1-2 business days
(Save 46%)
Other sellers (Paperback)
  • All (15) from $24.29   
  • New (11) from $24.64   
  • Used (4) from $24.29   

Overview

C# has matured over the past decade: It’s now a rich language with generics, functional programming concepts, and support for both static and dynamic typing. This palette of techniques provides great tools for many different idioms, but there are also many ways to make mistakes. In Effective C#, Second Edition, respected .NET expert Bill Wagner identifies fifty ways you can leverage the full power of the C# 4.0 language to express your designs concisely and clearly.

Effective C#, Second Edition, follows a clear format that makes it indispensable to hundreds of thousands of developers: clear, practical explanations, expert tips, and plenty of realistic code examples. Drawing on his unsurpassed C# experience, Wagner addresses everything from types to resource management to dynamic typing to multicore support in the C# language and the .NET framework. Along the way, he shows how to avoid common pitfalls in the C# language and the .NET environment. You’ll learn how to

  • Use both types of C# constants for efficiency and maintainability (see Item 2)
  • Employ immutable data types to promote multicore processing (see Item 20)
  • Minimize garbage collection, boxing, and unboxing (see Items 16 and 45)
  • Take full advantage of interfaces and delegates (see Items 22 though 25)
  • Make the most of the parallel framework (see Items 35 through 37)
  • Use duck typing in C# (see Item 38)
  • Spot the advantages of the dynamic and Expression types over reflection (see Items 42 and 43)
  • Assess why query expressions are better than loops (see Item 8)
  • Understand how generic covariance and contravariance affect your designs (see Item 29)
  • See how optional parameters can minimize the number of method overloads (see Item 10)

You’re already a successful C# programmer–this book will help you become an outstanding one.

Read More Show Less

Editorial Reviews

From the Publisher

“Being an effective .NET developer requires one to have a deep understanding of the language of their choice. Wagner’s book provides the reader with that knowledge via well-reasoned arguments and insight. Whether you’re new to C# or you’ve been using it for years, you’ll learn something new when you read this book.”

–Jason Bock, Principal Consultant, Magenic

“If you’re at all like me, you have collected a handful of C# language pearls that have immediately transformed your abilities as a professional developer. What you hold in your hands is quite possibly the best collection of these tips that have ever been assembled. Bill has managed to exceed my wildest expectations with the latest edition in his eponymous Effective C#.

–Bill Craun, Principal Consultant, Ambassador Solutions

Effective C#, Second Edition, is a must-read for anyone building high performance and/or highly scalable applications. Bill has that rare and awesome ability to take an amazingly complex problem and break it down into human, digestible, and understandable chunks.”

–Josh Holmes, Architect Evangelist, Microsoft

“Bill has done it again. This book is a concise collection of invaluable tips for any C# developer. Learn one tip every day, and you’ll become a much better C# developer after fifty days!”

–Claudio Lassala, Lead Developer, EPS Software/CODE Magazine

“A fountain of knowledge and understanding of the C# language. Bill gives insight to what happens under the covers of the .NET runtime based on what you write in your code and teaches pragmatic practices that lead to cleaner, easier to write, and more understandable code. A great mix of tips, tricks, and deep understanding–including things true since C# 1.0 up through new capabilities in C# 4.0–that every C# developer should read.”

–Brian Noyes, Chief Architect, IDesign Inc. (www.idesign.net)

Effective C# is a must-have for every C# developer. Period. Its pragmatic advice on code design is invaluable.”

–Shawn Wildermuth, Microsoft MVP (C#), Author, Trainer, and Speaker

“In this book Bill Wagner provides practical explanations of how to use the most important features in the C# language. His deep knowledge and sophisticated communication skills illuminate the new features in C# so that you can use them to write programs that are more concise and easier to maintain.”

–Charlie Calvert, Microsoft C# Community Program Manager

Read More Show Less

Product Details

  • ISBN-13: 9780321658708
  • Publisher: Addison-Wesley
  • Publication date: 3/19/2010
  • Series: Effective Software Development Series
  • Edition description: Second Edition
  • Edition number: 2
  • Pages: 328
  • Sales rank: 308,987
  • Product dimensions: 7.00 (w) x 9.10 (h) x 0.90 (d)

Meet the Author

With more than twenty years of experience, Bill Wagner, SRT Solutions cofounder, is a recognized expert in software design and engineering, specializing in C#, .NET, and the Azure platform. He serves as Michigan’s Regional Director for Microsoft and is a multiyear winner of Microsoft’s MVP award. An internationally recognized writer, Bill is the author of the first edition of this book and More Effective C# (Addison-Wesley, 2009) and currently writes a column on the Microsoft C# Developer Center. Bill earned a B.S. in computer science from the University of Illinois at Champaign-Urbana.

Read More Show Less

Table of Contents

Introduction xiii

Chapter 1: C# Language Idioms 1

Item 1: Use Properties Instead of Accessible Data Members 1

Item 2: Prefer readonly to const 8

Item 3: Prefer the is or as Operators to Casts 12

Item 4: Use Conditional Attributes Instead of #if 20

Item 5: Always Provide ToString() 28

Item 6: Understand the Relationships Among the Many Different Concepts of Equality 36

Item 7: Understand the Pitfalls of GetHashCode() 44

Item 8: Prefer Query Syntax to Loops 51

Item 9: Avoid Conversion Operators in Your APIs 56

Item 10: Use Optional Parameters to Minimize Method Overloads 60

Item 11: Understand the Attraction of Small Functions 64

Chapter 2: .NET Resource Management 69

Item 12: Prefer Member Initializers to Assignment Statements 74

Item 13: Use Proper Initialization for Static Class Members 77

Item 14: Minimize Duplicate Initialization Logic 79

Item 15: Utilize using and try/finally for Resource Cleanup 87

Item 16: Avoid Creating Unnecessary Objects 94

Item 17: Implement the Standard Dispose Pattern 98

Item 18: Distinguish Between Value Types and Reference Types 104

Item 19: Ensure That 0 Is a Valid State for Value Types 110

Item 20: Prefer Immutable Atomic Value Types 114

Chapter 3: Expressing Designs in C# 125

Item 21: Limit Visibility of Your Types 126

Item 22: Prefer Defining and Implementing Interfaces to Inheritance 129

Item 23: Understand How Interface Methods Differ from Virtual Methods 139

Item 24: Express Callbacks with Delegates 143

Item 25: Implement the Event Pattern for Notifications 146

Item 26: Avoid Returning References to Internal Class Objects 154

Item 27: Prefer Making Your Types Serializable 157

Item 28: Create Large-Grain Internet Service APIs 166

Item 29: Support Generic Covariance and Contravariance 171

Chapter 4: Working with the Framework 179

Item 30: Prefer Overrides to Event Handlers 179

Item 31: Implement Ordering Relations with IComparable and IComparer 183

Item 32: Avoid ICloneable 190

Item 33: Use the new Modifier Only to React to Base Class Updates 194

Item 34: Avoid Overloading Methods Defined in Base Classes 198

Item 35: Learn How PLINQ Implements Parallel Algorithms 203

Item 36: Understand How to Use PLINQ for I/O Bound Operations 215

Item 37: Construct Parallel Algorithms with Exceptions in Mind 220

Chapter 5: Dynamic Programming in C# 227

Item 38: Understand the Pros and Cons of Dynamic 227

Item 39: Use Dynamic to Leverage the Runtime Type of Generic Type Parameters 236

Item 40: Use Dynamic for Parameters That Receive Anonymous Types 239

Item 41: Use DynamicObject or IDynamicMetaObjectProvider for Data-Driven Dynamic Types 243

Item 42: Understand How to Make Use of the Expression API 254

Item 43: Use Expressions to Transform Late Binding into Early Binding 261

Item 44: Minimize Dynamic Objects in Public APIs 267

Chapter 6: Miscellaneous 275

Item 45: Minimize Boxing and Unboxing 275

Item 46: Create Complete Application-Specific Exception Classes 279

Item 47: Prefer the Strong Exception Guarantee 284

Item 48: Prefer Safe Code 294

Item 49: Prefer CLS-Compliant Assemblies 298

Item 50: Prefer Smaller, Cohesive Assemblies 303

Index 309

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing 1 Customer Reviews
  • Anonymous

    Posted February 12, 2011

    No text was provided for this review.

Sort by: Showing 1 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)