More Effective C#: 50 Specific Ways to Improve Your C#, 2nd Edition Front Cover

More Effective C#: 50 Specific Ways to Improve Your C#, 2nd Edition

Description

In More Effective C#, Second Edition, world-renowned .NET expert Bill Wagner identifies and illuminates 50 intermediate-to-advanced techniques for writing exceptionally robust and well-performing C# 7.0 code. Reflecting the growing sophistication of the C# language and its development community, Wagner presents powerful new solutions to problems you’re likely to encounter every day.

Through three editions of Effective C#, Wagner’s clear explanations, expert tips, and realistic code examples have proven invaluable to hundreds of thousands of developers. Now, he brings the same proven approach to C# 7.0, focusing especially on new features that help you perform familiar tasks more efficiently and effectively.

Drawing on his unsurpassed C# experience and key role on global C# standards committees, Wagner addresses object-oriented, functional, and service-oriented approaches to managing data with C#; better ways to express your intent to users and other programmers; and new opportunities to leverage powerful asynchronous and dynamic programming techniques.

  • Use properties instead of accessible data members (see Item 1)
  • Distinguish between value and reference types (see Item 4)
  • Understand relationships among multiple concepts of equality (see Item 9)
  • Avoid conversion operators in your APIs (see Item 11)
  • Understand how interface and virtual methods differ (see Item 15)
  • Avoid overloading methods defined in base classes (see Item 19)
  • Create method groups that are clear, minimal, and complete (see Item 22)
  • Enable immediate error reporting in iterators and async methods (see Item 26)
  • Use async methods for async work (see Item 27)
  • Avoid thread allocations and context switches (see Item 30)
  • Construct PLINQ parallel algorithms with exceptions in mind (see Item 36)
  • Use the thread pool instead of creating threads (see Item 37)
  • Use backgroundworker for cross-thread communication (see Item 38)
  • Use the smallest possible scope for lock handles (see Item 41)
  • Understand the pros and cons of dynamic programming (see Item 43)
  • Make full use of the expression API (item 46)
  • Minimize dynamic objects in public APIs (item 47)

You’re already a successful C# programmer: this book will make you an outstanding one.

Content Update Program: This book is part of the InformIT Content Update Program. As updates are made to C#, sections of this book will be updated or new sections will be added to match updates to the technologies. See inside for details.

Table of Contents

1. Working with Data Types
Item 1: Use Properties Instead of Accessible Data Members
Item 2: Prefer Implicit Properties for Mutable Data
Item 3: Prefer Immutability for Value Types
Item 4: Distinguish Between Value Types and Reference Types
Item 5: Ensure That 0 Is a Valid State for Value Types
Item 6: Ensure That Properties Behave Like Data
Item 7: Limit Type Scope by Using Anonymous Types
Item 8: Define Local Functions on Anonymous Types
Item 9: Understand the Relationships Among the Many Different Concepts of Equality
Item 10: Understand the Pitfalls of GetHashCode()

2. API Design
Item 11: Avoid Conversion Operators in Your APIs
Item 12: Use Optional Parameters to Minimize Method Overloads
Item 13: Limit Visibility of Your Types
Item 14: Prefer Defining and Implementing Interfaces to Inheritance
Item 15: Understand How Interface Methods Differ from Virtual Methods
Item 16: Implement the Event Pattern for Notifications
Item 17: Avoid Returning References to Internal Class Objects
Item 18: Prefer Overrides to Event Handlers
Item 19: Avoid Overloading Methods Defined in Base Classes
Item 20: Understand How Events Increase Runtime Coupling Among Objects
Item 21: Declare Only Nonvirtual Events
Item 22: Create Method Groups That Are Clear, Minimal, and Complete
Item 23: Give Partial Classes Partial Methods for Constructors, Mutators, and Event Handlers
Item 24: Avoid ICloneable because it limits your design choices
Item 25: Limit Array Parameters to Params Arrays
Item 26: Enable Immediate Error Reporting in Iterators and Async Methods using Local Functions

3. Task based Asynchronous Programming
Item 27: Use Async methods for async work
Item 28: Never Write Async void Methods
Item 29: Avoid Composing Synchronous and Asynchronous Methods
Item 30: Use async Methods to Avoid Thread Allocations and Context Switches
Item 31: Avoid Marshalling Context Unnecessarily
Item 32: Compose Asynchronous Work Using Task Objects
Item 33: Consider Implementing the Task Cancellation Protocol
Item 34: Cache Generalized Async Return types

4. Parallel Processing
Item 35: Learn How PLINQ Implements Parallel Algorithms
Item 36: Construct Parallel Algorithms with Exceptions in Mind
Item 37: Use the Thread Pool Instead of Creating Threads
Item 38: Use BackgroundWorker for Cross-Thread Communication
Item 39: Understand Cross-Thread Calls in XAML environments

To access the link, solve the captcha.