did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780321245663

Effective C# 50 Specific Ways to Improve Your C#

by
  • ISBN13:

    9780321245663

  • ISBN10:

    0321245660

  • Edition: 1st
  • Format: Paperback
  • Copyright: 2004-12-03
  • Publisher: Addison-Wesley Professional
  • View Upgraded Edition
  • Purchase Benefits
  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $59.99

Summary

Like Effective C++ and Effective Java, this book is full of practical advice and tips from a recognized expert in the field.

Author Biography

Bill Wagner is co-founder of and .NET consultant for SRT Solutions.

Table of Contents

Introduction
Language Elements
Always Use Properties Instead of Accessible Data Members
Prefer readonly to const
Prefer the is or as Operators to Casts
Use Conditional Attributes Instead of #if
Always Provide ToString()
Distinguish Between Value Types and Reference Types
Prefer Immutable Atomic Value Types
Ensure That 0 Is a Valid State for Value Types
Understand the Relationships Among ReferenceEquals(),static Equals(), instance Equals(), and operator==
Understand the Pitfalls of GetHashCode()
Prefer foreach Loops
NET Resource Management
Prefer Variable Initializers to Assignment Statements
Initialize Static Class Members with Static Constructors
Utilize Constructor Chaining
Utilize using and try/finally for Resource Cleanup
Minimize Garbage
Minimize Boxing and Unboxing
Implement the Standard Dispose Pattern
Expressing Designs with C#
Prefer Defining and Implementing Interfaces to Inheritance
Distinguish Between Implementing Interfaces and Overriding Virtual Functions
Express Callbacks with Delegates
Define Outgoing Interfaces with Events
Avoid Returning References to Internal Class Objects
Prefer Declarative to Imperative Programming
Prefer Serializable Types
Implement Ordering Relations with IComparable and Icompare
Table of Contents provided by Publisher. All Rights Reserved.

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

This book is designed to offer practical advice for the programmer on how to improve productivity when using the C# language and the .NET libraries. In it, I have comprised 50 key items, or minitopics, related to the most-frequently-asked questions that I (and other C# consultants) have encountered while working with the C# community. I started using C# after more than 10 years of C++ development, and it seems that many C# developers are following suit. Throughout the book, I discuss where following C++ practices may cause problems in using C#. Other C# developers are coming to the language with a strong Java background; they may find some of these passages rather obvious. Because some of the best practices change from Java to C#, I encourage Java developers to pay special attention to the discussions on value types (see Chapter 1, "C# Language Elements"). In addition, the .NET Garbage Collector behaves differently than the JVM Garbage Collector (see Chapter 2, ".NET Resource Management"). The items in this book are the collection of recommendations that I most often give developers. Although not all items are universal, most of the items can be easily applied to everyday programming scenarios. These include discussions on Properties (Item 1), Conditional Compilation (Item 4), Immutable Types (Item 7), Equality (Item 9), ICloneable (Item 27), and the new Modifier (Item 29). It has been my experience that, in most situations, decreasing development time and writing good code are the primary goals of the programmer. Certain scientific and engineering applications may place the highest premium on the overall performance of the system. Still, for others, it's all about the scalability. Depending on your goals, you might find particular information more (or less) relevant under certain circumstances. To address this, I have tried to explain the goals in detail. My discussions on readonly and const (Item 2), Serializable Types (Item 25), CLS Compliance (Item 31), Web Methods (Item 34), and DataSets (Item 41) assume certain design goals. Those goals are spelled out in these items, so that you can decide what is most applicable for you in your given situation. Although each item in Effective C# stands alone, it is important to understand that the items have been organized around major topics, such as C# language syntax, resource management, and object and component design. This is no accident. My goal is to maximize learning the material covered in the book by leveraging and building each item on earlier items. Don't let that keep you from using it as a reference, though. If you have specific questions, this book functions well as the ideal "ask-me" tool. Please keep in mind that this is not a tutorial or a guide to the language, nor is it going to teach you C# syntax or structure. My goal is to provide guidance on the best constructs to use in different situations. Who Should Read this Book? Effective C# is written for professional developers, those programmers who use C# in their daily work lives. It assumes that you have some experience with object-oriented programming and at least one language in the C family: C, C++, C#, or Java. Developers with a Visual Basic 6 background should be familiar with both the C# syntax and object-oriented design before reading this book. Additionally, you should have some experience with the major areas of .NET: Web Services, ADO.NET, Web forms, and Windows Forms. I reference these concepts throughout the book. To fully take advantage of this book, you should understand the way the .NET environment handles assemblies, the Microsoft Intermediate Language (MSIL), and executable code. The C# compiler produces assemblies that contain MSIL, which I often abbreviate as IL. When an assembly is loaded, the Just In Time (JIT) Compiler converts that MSIL into machine-executable code. The C# compiler does perform some optimizations, but the JIT compil

Rewards Program