Effective C#: 50 Specific Ways to Improve Your C# and over 2 million other books are available for Amazon Kindle . Learn more


or
Sign in to turn on 1-Click ordering.
More Buying Choices
Have one to sell? Sell yours here
Sorry, this item is not available in
Image not available for
Colour:
Image not available

 
Start reading Effective C# on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Effective C#: 50 Specific Ways to Improve Your C# [Paperback]

Bill Wagner
4.0 out of 5 stars  See all reviews (2 customer reviews)
RRP: 36.99
Price: 31.47 & FREE Delivery in the UK. Details
You Save: 5.52 (15%)
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Only 1 left in stock.
Dispatched from and sold by Amazon. Gift-wrap available.
Want it Friday, 1 Aug.? Choose Express delivery at checkout. Details

Formats

Amazon Price New from Used from
Kindle Edition 26.36  
Paperback 31.47  
There is a newer edition of this item:
More Effective C#: 50 Specific Ways to Improve Your C# (Effective Software Development) More Effective C#: 50 Specific Ways to Improve Your C# (Effective Software Development) 2.5 out of 5 stars (2)
34.99
In stock.

Book Description

3 Dec 2004 0321245660 978-0321245663 1

"This book really demonstrates Bill's strengths as a writer and programmer. In a very short amount of time, he is able to present an issue, fix it and conclude it; each chapter is tight, succinct, and to the point."

—Josh Holmes, Independent Contractor

"The book provides a good introduction to the C# language elements from a pragmatic point of view, identifying best practices along the way, and following a clear and logical progression from the basic syntax to creating components to improving your code writing skills. Since each topic is covered in short entries, it is very easy to read and you'll quickly realize the benefits of the book."

—Tomas Restrepo, Microsoft MVP

"The book covers the basics well, especially with respect to the decisions needed when deriving classes from System.Object. It is easy to read with examples that are clear, concise and solid. I think it will bring good value to most readers."

—Rob Steel, Central Region Integration COE & Lead Architect, Microsoft

"Effective C# provides the C# developer with the tools they need to rapidly grow their experience in Visual C# 2003 while also providing insight into the many improvements to the language that will be hitting a desktop near you in the form of Visual C# 2005."

—Doug Holland, Precision Objects

"Part of the point of the .NET Framework—and the C# Language, in particular—is to let the developer focus solving customer problems and deliver product, rather than spending hours (or even weeks) writing plumbing code. Bill Wagner's Effective C#, not only shows you what's going on behind the scenes, but shows you how to take advantage of particular C# code constructs. Written in a dispassionate style that focuses on the facts—and just the facts—of writing effective C# code, Wagner's book drills down into practices that will let you write C# applications and components that are easier to maintain as well as faster to run. I'm recommending Effective C# to all students of my .NET BootCamp and other C#-related courses."

—Richard Hale Shaw, www.RichardHaleShawGroup.com

C#'s resemblances to C++, Java, and C make it easier to learn, but there's a downside: C# programmers often continue to use older techniques when far better alternatives are available. In Effective C#, respected .NET expert Bill Wagner identifies fifty ways you can start leveraging the full power of C# in order to write faster, more efficient, and more reliable software.

Effective C# follows the format that made Effective C++ (Addison-Wesley, 1998) and Effective Java (Addison-Wesley, 2001) 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 value types to assemblies, exceptions to reflection. Along the way, he shows exactly how to avoid dozens of common C# performance and reliability pitfalls. You'll learn how to:

  • Use both types of C# constants for efficiency and maintainability, see item 2

  • Use immutable data types to eliminate unnecessary error checking, see item 7

  • Avoid the C# function that'll practically always get you in trouble, see item 10

  • Minimize garbage collection, boxing, and unboxing, see items 16 and 17

  • Take full advantage of interfaces and delegates, see items 19 though 22

  • Create CLS compliant assemblies that use noncompliant C# language features, see item 30

  • Improve reliability and maintainability by creating small, cohesive assemblies, see item 32

  • Leverage the full power of .NET's runtime diagnostics, see item 36

  • Know when—and when not—to use reflection, see items 42 and 43

  • Preview the major enhancements in C# 2.0, see item 49

  • You're already a successful C# programmer—this book can help you become an outstanding one.

Bill Wagner is co-founder of and .NET consultant for SRT Solutions. A nationally recognized independent expert on .NET, he has been a regular contributor to ASP.NET Pro Magazine, Visual Studio Magazine, and the .NET Insight newsletter. In addition to being a Microsoft Regional Director, he is also active in the Southeast Michigan .NET User Group and the Ann Arbor Computing Society. He is author of The C# Core Language Little Black Book (The Coriolis Group, 2002).


© Copyright Pearson Education. All rights reserved.



Product details

  • Paperback: 336 pages
  • Publisher: Addison Wesley; 1 edition (3 Dec 2004)
  • Language: English
  • ISBN-10: 0321245660
  • ISBN-13: 978-0321245663
  • Product Dimensions: 2 x 17.5 x 22.5 cm
  • Average Customer Review: 4.0 out of 5 stars  See all reviews (2 customer reviews)
  • Amazon Bestsellers Rank: 591,487 in Books (See Top 100 in Books)
  • See Complete Table of Contents

More About the Author

Personal Biography
With more than 20 years experience in software design and engineering, Bill Wagner has led the design on many successful engineering and enterprise Microsoft Windows products and adapted legacy systems for Windows.

In 2000, he started using .NET and now spends his time facilitating the adoption of .NET in clients' product and enterprise development. Knowledgeable in all .NET areas, Bill's principal strengths include the C# language, the core framework, Smart Clients, and Service Oriented Architecture and design.

In addition to his role at SRT Solutions, Bill serves as Michigan's Regional Director for Microsoft. In 2005, Microsoft awarded him "C# Most Valuable Professional (MVP)" status. These honorary positions allow Bill previews of upcoming technologies and help ensure SRT clients the most advanced and cutting-edge solutions for their technology projects.

An internationally recognized author on the C# language evolution, Smart Clients and enterprise design, Bill has been a contributing editor, editorial board member and regular columnist for over a decade with his tutorials and advanced essays published in MSDN Magazine, MSDN Online, .NET Insight, and .NET DJ. He also writes a monthly column for Visual Studio Magazine, and a monthly column on the MSDN C# team developer center.

Bill's book, Effective C#, was published in 2004. His next book, More Effective C#, was distributed in 2008.

Bill earned a Bachelor of Science degree in computer science from the University of Illinois at Champaign-Urbana.



Product Description

From the Back Cover

"This book really demonstrates Bill's strengths as a writer and programmer. In a very short amount of time, he is able to present an issue, fix it and conclude it; each chapter is tight, succinct, and to the point."

—Josh Holmes, Independent Contractor

"The book provides a good introduction to the C# language elements from a pragmatic point of view, identifying best practices along the way, and following a clear and logical progression from the basic syntax to creating components to improving your code writing skills. Since each topic is covered in short entries, it is very easy to read and you'll quickly realize the benefits of the book."

—Tomas Restrepo, Microsoft MVP

"The book covers the basics well, especially with respect to the decisions needed when deriving classes from System.Object. It is easy to read with examples that are clear, concise and solid. I think it will bring good value to most readers."

—Rob Steel, Central Region Integration COE & Lead Architect, Microsoft

"Effective C# provides the C# developer with the tools they need to rapidly grow their experience in Visual C# 2003 while also providing insight into the many improvements to the language that will be hitting a desktop near you in the form of Visual C# 2005."

—Doug Holland, Precision Objects

"Part of the point of the .NET Framework—and the C# Language, in particular—is to let the developer focus solving customer problems and deliver product, rather than spending hours (or even weeks) writing plumbing code. Bill Wagner's Effective C#, not only shows you what's going on behind the scenes, but shows you how to take advantage of particular C# code constructs. Written in a dispassionate style that focuses on the facts—and just the facts—of writing effective C# code, Wagner's book drills down into practices that will let you write C# applications and components that are easier to maintain as well as faster to run. I'm recommending Effective C# to all students of my .NET BootCamp and other C#-related courses."

—Richard Hale Shaw, www.RichardHaleShawGroup.com

C#'s resemblances to C++, Java, and C make it easier to learn, but there's a downside: C# programmers often continue to use older techniques when far better alternatives are available. In Effective C#, respected .NET expert Bill Wagner identifies fifty ways you can start leveraging the full power of C# in order to write faster, more efficient, and more reliable software.

Effective C# follows the format that made Effective C++ (Addison-Wesley, 1998) and Effective Java (Addison-Wesley, 2001) 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 value types to assemblies, exceptions to reflection. Along the way, he shows exactly how to avoid dozens of common C# performance and reliability pitfalls. You'll learn how to:

  • Use both types of C# constants for efficiency and maintainability, see item 2

  • Use immutable data types to eliminate unnecessary error checking, see item 7

  • Avoid the C# function that'll practically always get you in trouble, see item 10

  • Minimize garbage collection, boxing, and unboxing, see items 16 and 17

  • Take full advantage of interfaces and delegates, see items 19 though 22

  • Create CLS compliant assemblies that use noncompliant C# language features, see item 30

  • Improve reliability and maintainability by creating small, cohesive assemblies, see item 32

  • Leverage the full power of .NET's runtime diagnostics, see item 36

  • Know when—and when not—to use reflection, see items 42 and 43

  • Preview the major enhancements in C# 2.0, see item 49

  • You're already a successful C# programmer—this book can help you become an outstanding one.

Bill Wagner is co-founder of and .NET consultant for SRT Solutions. A nationally recognized independent expert on .NET, he has been a regular contributor to ASP.NET Pro Magazine, Visual Studio Magazine, and the .NET Insight newsletter. In addition to being a Microsoft Regional Director, he is also active in the Southeast Michigan .NET User Group and the Ann Arbor Computing Society. He is author of The C# Core Language Little Black Book (The Coriolis Group, 2002).


© Copyright Pearson Education. All rights reserved.

About the Author

Introduction. 1. C# Language Elements. Item 1 - Always Use Properties Instead of Accessible Data Members. Item 2 - Prefer readonly to const. Item 3 - Prefer the is or as Operators to Casts. Item 4 - Use Conditional Attributes Instead of #if. Item 5 - Always Provide ToString(). Item 6 - Distinguish Between Value Types and Reference Types. Item 7 - Prefer Immutable Atomic Value Types. Item 8 - Ensure That 0 Is a Valid State for Value Types. Item 9 - Understand the Relationships Among ReferenceEquals(),static Equals(), instance Equals(), and operator==. Item 10 - Understand the Pitfalls of GetHashCode(). Item 11 - Prefer foreach Loops. 2. .NET Resource Management. Item 12 - Prefer Variable Initializers to Assignment Statements. Item 13 - Initialize Static Class Members with Static Constructors. Item 14 - Utilize Constructor Chaining. Item 15 - Utilize using and try/finally for Resource Cleanup. Item 16 - Minimize Garbage. Item 17 - Minimize Boxing and Unboxing. Item 18 - Implement the Standard Dispose Pattern. 3. Expressing Designs with C#. Item 19 - Prefer Defining and Implementing Interfaces to Inheritance. Item 20 - Distinguish Between Implementing Interfaces and Overriding Virtual Functions. Item 21 - Express Callbacks with Delegates. Item 22 - Define Outgoing Interfaces with Events. Item 23 - Avoid Returning References to Internal Class Objects. Item 24 - Prefer Declarative to Imperative Programming. Item 25 - Prefer Serializable Types. Item 26 - Implement Ordering Relations with IComparable and Icomparer. Item 27 - Avoid Icloneable. Item 28 - Avoid Conversion Operators. Item 29 - Use the new Modifier Only When Base Class Updates Mandate It. 4. Creating Binary Components. Item 30 - Prefer CLS-Compliant Assemblies. Item 31 - Prefer Small, Simple Functions. Item 32 - Prefer Smaller, Cohesive Assemblies. Item 33 - Limit Visibility of Your Types. Item 34 - Create Large-Grain Web APIs. 5. Working with the Framework. Item 35 - Prefer Overrides to Event Handlers. Item 36 - Leverage .NET Runtime Diagnostics. Item 37 - Use the Standard Configuration Mechanism. Item 38 - Utilize and Support Data Binding. Item 39 - Use .NET Validation. Item 40 - Match Your Collection to Your Needs. Item 41 - Prefer DataSets to Custom Structures. Item 42 - Utilize Attributes to Simplify Reflection. Item 43 - Don't Overuse Reflection. Item 44 - Create Complete Application-Specific Exception Classes. 6. Miscellaneous. Item 45 - Prefer the Strong Exception Guarantee. Item 46 - Minimize Interop. Item 47 - Prefer Safe Code. Item 48 - Learn About Tools and Resources. Item 49 - Prepare for C# 2.0. Item 50 - Learn About the ECMA Standard. Index.

Inside This Book (Learn More)
First Sentence
Why should you change what you are doing today if it works? Read the first page
Browse Sample Pages
Front Cover | Copyright | Table of Contents | Excerpt | Index
Search inside this book:


Customer Reviews

4 star
0
2 star
0
1 star
0
4.0 out of 5 stars
4.0 out of 5 stars
Most Helpful Customer Reviews
14 of 15 people found the following review helpful
5.0 out of 5 stars Another quality 'Effective' book 25 Nov 2005
Format:Paperback|Verified Purchase
Another good book in the Effective series. Though if like me you have read Effective Java and have come from a Java background then you will probably have seen variations on the same items before. For instance this book has its own C# slant on the equals contract and hash codes that many Java programmers will have seen before. The items are still worth reading, as though the general theory may be known, the C# specifics are new.
This book is very open to people from a wide range of programming backgrounds, but a number of items do seem to be based on beating old style techniques out of Windows C++ programmers. If you are an old Windows C++ programmers it may seem that this book was written just for you.

My main criticism of this book is that I thought it had a tendency to describe items in an overly long and complicated way. But this is just a style issue and doesn't detract too much from the content. The things I loved the most were the debunking of common myths, such as 'avoid foreach' and 'avoid DataSets'. And my favourite item was a good example of how to program custom attributes to make reflection simpler and easier. This was a great example of attributes and a valid use of reflection and was the prefect precursor to the item 'Don't overuse reflection'.
Like all the 'Effective' books before it this is one to read once to get the general understanding, then to leave on your desk to reference again and again when the items become relevant to what you are doing at that moment.
Comment | 
Was this review helpful to you?
8 of 9 people found the following review helpful
3.0 out of 5 stars excellent book let down by poor editing 26 May 2006
By amazion
Format:Paperback
This is a great book. However it's full of misprints and unnecessary re-iterations. I notice that Scott Meyers (of 'Effective C++' fame) was consulting editor, but it has nothing of the lean, concise style that the original effective c++ book had.

Having said that, I wouldn't be without it, but I hope the second edition is a bit tidier and 90 pages shorter!
Comment | 
Was this review helpful to you?
Most Helpful Customer Reviews on Amazon.com (beta)
Amazon.com: 4.4 out of 5 stars  31 reviews
24 of 25 people found the following review helpful
4.0 out of 5 stars Not for the C# newbie. 7 July 2005
By Steven - Published on Amazon.com
Format:Paperback
Wow, what at relief this book is, really.

I have read numerous C# books and most of them do about the same thing. They touch base on a wide array of topics (database, oop, multi-threading, arrays, indexers...etc), thus you really never learn any of the more advanced stuff. Really, how many times have you read about an animal hierarchy whilst browsing through an OOP section of a programming book?

Well, in comes Effective C#. This book doesn't really focus much on specific topics (like how to do database programming and such), instead, you learn 50 specific ways to improve your C# code. For example: You have undoubtedly read about properties if you've read any basic C# book... You probably think you know everything there is to know about them... I mean, really, generally we use public properties to access private variables in a class. Well, one of the topics in this book focuses on properties - I never realized how much more there is to learn about something as simple as a property!

This book is a thinker. You will browse these pages and think to yourself "Wow! I never realized you could do that!". Your expertise on C# will definitely go up a notch or two. That brings me to my next point: This is no easy read! Even if you feel that you're at an intermediate level, you will find some of the text difficult to absorb on the first couple passes. This is definitely a techie book through and through (which isn't all that bad), but at times it may seem slightly dry.

If you are a beginner then I might pass this book up for a later day. If you are intermediate - advanced then I would definitely think about picking this baby up.
34 of 38 people found the following review helpful
5.0 out of 5 stars Not the Book I Was Expecting 24 July 2005
By Martin L. Shoemaker - Published on Amazon.com
Format:Paperback
FULL DISCLOSURE: I know Bill Wagner pretty well, and consider him a friend. I don't think that has colored this review, but you have a right to know. (If you doubt my objectivity, consider that I have now purchased TWO copies of this book, even though I probably could have gotten one or two for free. It's worth it!)

Back when I was a C++ programmer, there was one book everyone said I simply had to read: Effective C++ by Scott Meyers. And they were right: when I read that book, I summarized it as "Here are 50 mistakes you're making in your C++ code right now, and you don't even know it." (Note: the latest edition has been expanded to 55 mistakes.) So now that I'm a C# programmer, I eagerly looked forward to Effective C# (edited by Meyers), because I wanted that same sort of "Aha!" enlightenment.

Well, Bill Wagner failed to deliver that enlightenment. But that's a good thing, actually, and something he couldn't help. But to understand why, we have to return to Scott Meyers.

After the 50 amazingly simple improvements in Effective C++, Meyers wrote More Effective C++; and I characterized that book as, "35 really deep subjects that you have to think about and understand. Some of them will apply to your work. Some of them won't. None of them will be easy. But you really have to think about them." See, Meyers covered all the simple, universal problems in his first book, making it darned hard to make any simple, obvious C++ mistakes. That meant his second book had to cover deeper design concerns, many of which apply only in particular circumstances.

And herein lies the difference for Wagner's book. See, a generation of C++ programmers learned and internalized Meyers's lessons -- including the Microsoft team who created the C# language. When they built their C++-inspired (and Java-inspired) language, they built in a lot of the safeguards and limits that Meyers advocated as a standard practice for C++. They also built in best practices from other sources. So it's my contention that the C# equivalent to Effective C++ can't really be written. The language won't allow it.

So what Wagner has written really falls somewhere between Effective C++ and More Effective C++. There are some simple "Aha!" tips; but there are a lot more deep design concerns. That's really what the C# programmer needs, after all; and that's what Wagner delivers in a very fine fashion.

Now Wagner can explain these topics better than I can, so I'm not going to try. But I do want to comment on the items I found most useful:

5. Always provide ToString(). Your maintenance and client coders will thank you.

15. Utilize using and try/finally for Resource Cleanup. And 18. Implement the Standard Dispose Pattern. .NET pretty much solves memory leaks; but memory is only the most commonly leaked resource. And in solving memory leaks, they made it harder to manage certain other resources. In these two items, Wagner shows how to do the best job you can.

I wish I could say I was following every tip in this book; but it's hard to break bad habits. Read this book before you form bad habits yourself.

Note that the original printing of this book had a lot of typos where words rantogether. I now have a copy of the second printing, where those all seem to be fixed.
13 of 16 people found the following review helpful
3.0 out of 5 stars Four Stars : Excellent content, but the writing could be a bit more clear 26 Nov 2006
By Damon Slye - Published on Amazon.com
Format:Paperback
First off, since writing my initial review, I find myself continually referring to this book. It has worn well. I wish I could change my rating from 3 to 4 stars. Unfortunately Amazon's review system doesn't allow that (only 3 stars for them!).

While there are many books that teach the C# languague, this is the only book I've found that offers advice on how to effectively use the language once you know it. It is unique and therefore indispensible. It's a "must-read" for any serious C# programmer.

The recommendations will help you understand C# so that you can write programs that are faster, more efficient, more maintainable, and easier to understand. Specific topics include things like value-types versus reference-types, "boxing" and "unboxing", minimizing garbage, the advantages of the operators "as" and "is" over casts, and so on.

I believe the writing and explanations could be more clear and concise. I wish the editors had spent a little more time cleaning up the text. Also, A second edition that assumes C# 2.0 should be released, since some of the recommendations deal with shortcomings of C# 1.0 that have been fixed by C# 2.0. Also, I found a couple small errors. For example, "as" is not always faster than a cast-- in some cases they generate code that is exactly the same speed. However, that's a trifling point.

I recommend this book.
3 of 3 people found the following review helpful
5.0 out of 5 stars Great book 29 Dec 2009
By Alan Fryer - Published on Amazon.com
Format:Paperback|Verified Purchase
As a manager, I look for books that can help me but also help my team. This book did both. It is the C# version of the effective C++ books.

To me it is a must read for engineers writing/reviewing code in C#.

The only problem with it is that the language is a bit of a moving target so the most effective ways to use C# is changing. To me, instead of having an effective C# book and a more effective C# book they should have had just a second edition of the first. This probably is not likely to be solved as I imagine many will be just digesting C# 3.0 with 4.0 looming on the horizon. This, however, is beyond the authors control.
3 of 3 people found the following review helpful
5.0 out of 5 stars Who wants to be ineffective 12 Sep 2009
By Wallace - Published on Amazon.com
Format:Paperback|Verified Purchase
If want to employ and understand the reason behind best practices in C# development, then this book and it's sequel More Effective C#: 50 Specific Ways to Improve Your C# will prove invaluable.

I'm taking it slow, reading one tip a day and reviewing the title of previously read tips each day in hopes to make these "Specific Ways" part of my nature as a C# developer. Several of them, such as "Prefer Properties to Accessible Members" were already apart of my normal practice, but others such as benefits of preferring "Conditional Attributes Instead of #if" were a surprise :-)

Also in the process of reading C# in Depth: What you need to master C# 2 and 3 and highly recommend it as well!... must haves for developers who strive to be experts at their craft.
Were these reviews helpful?   Let us know
Search Customer Reviews
Only search this product's reviews

Customer Discussions

This product's forum
Discussion Replies Latest Post
No discussions yet

Ask questions, Share opinions, Gain insight
Start a new discussion
Topic:
First post:
Prompts for sign-in
 

Search Customer Discussions
Search all Amazon discussions
   


Look for similar items by category


Feedback