Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 3rd Edition

Book Description

Master Today's Best Practices for Building Reusable .NET Frameworks, Libraries, and Components

“.NET Core [contains] advances important to cloud application developers: performance, resource utilization, container support, and others. This third edition of Framework Design Guidelines adds guidelines related to changes that the .NET team adopted during transition from the world of client-server application to the world of the Cloud.”
–From the Foreword by Scott Guthrie

Framework Design Guidelines has long been the definitive guide to best practices for developing components and component libraries in Microsoft .NET. Now, this third edition has been fully revised to reflect game-changing API design innovations introduced by Microsoft through eight recent updates to C#, eleven updates to .NET Framework, and the emergence and evolution of .NET Core.

Three leading .NET architects share the same guidance Microsoft teams are using to evolve .NET, so you can design well-performing components that feel like natural extensions to the platform. Building on the book's proven explanatory style, the authors and expert annotators offer insider guidance on new .NET and C# concepts, including major advances in asynchronous programming and lightweight memory access. Throughout, they clarify and refresh existing content, helping you take full advantage of best practices based on C# 8, .NET Framework 4.8, and .NET Core.

  • Discover which practices should always, generally, rarely, or never be used–including practices that are no longer recommended
  • Learn the general philosophy and fundamental principles of modern framework design
  • Explore common framework design patterns with up-to-date C# examples
  • Apply best practices for naming, types, extensibility, and exceptions
  • Learn how to design libraries that scale in the cloud
  • Master new async programming techniques utilizing Task and ValueTask
  • Make the most of the Memory and Span types for lightweight memory access

This guide is an indispensable resource for everyone who builds reusable .NET-based frameworks, libraries, or components at any scale: large system frameworks, medium-size reusable layers of large distributed systems, extensions to system frameworks, or even small shared components.

Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.

Table of Contents

  1. Cover Page
  2. About This eBook
  3. Halftitle Page
  4. Title Page
  5. Copyright Page
  6. Dedication Page
  7. Contents
  8. Figures
  9. Tables
  10. Foreword
  11. Foreword to the Second Edition
  12. Foreword to the First Edition
  13. Preface
    1. Guideline Presentation
    2. Language Choice and Code Examples
    3. About This Book
  14. Acknowledgments
  15. About the Authors
  16. About the Annotators
  17. 1. Introduction
    1. 1.1 Qualities of a Well-Designed Framework
  18. 2. Framework Design Fundamentals
    1. 2.1 Progressive Frameworks
    2. 2.2 Fundamental Principles of Framework Design
    3. Summary
  19. 3. Naming Guidelines
    1. 3.1 Capitalization Conventions
    2. 3.2 General Naming Conventions
    3. 3.3 Names of Assemblies, DLLs, and Packages
    4. 3.4 Names of Namespaces
    5. 3.5 Names of Classes, Structs, and Interfaces
    6. 3.6 Names of Type Members
    7. 3.7 Naming Parameters
    8. 3.8 Naming Resources
    9. Summary
  20. 4. Type Design Guidelines
    1. 4.1 Types and Namespaces
    2. 4.2 Choosing Between Class and Struct
    3. 4.3 Choosing Between Class and Interface
    4. 4.4 Abstract Class Design
    5. 4.5 Static Class Design
    6. 4.6 Interface Design
    7. 4.7 Struct Design
    8. 4.8 Enum Design
    9. 4.9 Nested Types
    10. 4.10 Types and Assembly Metadata
    11. 4.11 Strongly Typed Strings
    12. Summary
  21. 5. Member Design
    1. 5.1 General Member Design Guidelines
    2. 5.2 Property Design
    3. 5.3 Constructor Design
    4. 5.4 Event Design
    5. 5.5 Field Design
    6. 5.6 Extension Methods
    7. 5.7 Operator Overloads
    8. 5.8 Parameter Design
    9. 5.9 Using Tuples in Member Signatures
    10. Summary
  22. 6. Designing for Extensibility
    1. 6.1 Extensibility Mechanisms
    2. 6.2 Base Classes
    3. 6.3 Sealing
    4. Summary
  23. 7. Exceptions
    1. 7.1 Exception Throwing
    2. 7.2 Choosing the Right Type of Exception to Throw
    3. 7.3 Using Standard Exception Types
    4. 7.4 Designing Custom Exceptions
    5. 7.5 Exceptions and Performance
    6. Summary
  24. 8. Usage Guidelines
    1. 8.1 Arrays
    2. 8.2 Attributes
    3. 8.3 Collections
    4. 8.4 DateTime and DateTimeOffset
    5. 8.5 ICloneable
    6. 8.6 IComparable<T> and IEquatable<T>
    7. 8.7 IDisposable
    8. 8.8 Nullable<T>
    9. 8.9 Object
    10. 8.10 Serialization
    11. 8.11 Uri
    12. 8.12 System.Xml Usage
    13. 8.13 Equality Operators
  25. 9. Common Design Patterns
    1. 9.1 Aggregate Components
    2. 9.2 The Async Patterns
    3. 9.3 Dependency Properties
    4. 9.4 Dispose Pattern
    5. 9.5 Factories
    6. 9.6 LINQ Support
    7. 9.7 Optional Feature Pattern
    8. 9.8 Covariance and Contravariance
    9. 9.9 Template Method
    10. 9.10 Timeouts
    11. 9.11 XAML Readable Types
    12. 9.12 Operating on Buffers
    13. 9.13 And in the End...
  26. A. C# Coding Style Conventions
    1. A.1 General Style Conventions
    2. A.2 Naming Conventions
    3. A.3 Comments
    4. A.4 File Organization
  27. B. Obsolete Guidance
    1. B.3 Obsolete Guidance from Naming Guidelines
    2. B.4 Obsolete Guidance from Type Design Guidelines
    3. B.5 Obsolete Guidance from Member Design
    4. B.7 Obsolete Guidance from Exceptions
    5. B.8 Obsolete Guidance from Usage Guidelines
    6. B.9 Obsolete Guidance from Common Design Patterns
  28. C. Sample API Specification
    1. Specification: Stopwatch
    2. Scenarios and User Experience
    3. Requirements
    4. Design
    5. Q & A
  29. D. Breaking Changes
    1. D.1 Modifying Assemblies
    2. D.2 Adding Namespaces
    3. D.3 Modifying Namespaces
    4. D.4 Moving Types
    5. D.5 Removing Types
    6. D.6 Modifying Types
    7. D.7 Adding Members
    8. D.8 Moving Members
    9. D.9 Removing Members
    10. D.10 Overloading Members
    11. D.11 Changing Member Signatures
    12. D.12 Changing Behavior
    13. D.13 A Final Note
  30. Glossary
  31. Index
  32. Credits
  33. Code Snippets

Product Information

  • Title: Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 3rd Edition
  • Author(s): Krzysztof Cwalina, Jeremy Barton, Brad Abrams
  • Release date: June 2020
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780135896457