ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
Framework Design Guidelines
Conventions, Idioms, and Patterns for Reusable .NET Libraries
Third Edition
Krzysztof Cwalina
Jeremy Barton
Brad Abrams
Boston Columbus New York San Francisco Amsterdam Cape Town
Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City
So Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The .NET logo is either a registered trademark or trademark of Microsoft Corporation in the United States and/or other countries and is used under license from Microsoft.
Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2020935344
Copyright 2020 Pearson Education, Inc.
Cover image: Jakub Krechowicz/Shutterstock
All rights reserved. This publication is protected by copyright, and permission must be obtained from
the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearson.com/permissions/.
ISBN-13: 978-0-13-589646-4
ISBN-10: 0-13-589646-0
ScoutAutomatedPrintCode
To my wife, Ela,
for her support throughout the long process of
writing this book, and to my parents, Jadwiga and Janusz,
for their encouragement.
Krzysztof Cwalina
To my lovely wife, Janine.
I didn't fully appreciate before why authors always dedicate
books to their spouse, and now I do.
So, thank you. I'm sorry. I probably have time now for whatever those things were that you wanted me to do while I was writing.
Jeremy Barton
To my wife, Tamara:
Your love and patience strengthen me.
Brad Abrams
Figures
Tables
Foreword
When we designed the .NET platform, we wanted it to be the most productive platform for enterprise application development of the time. Twenty years ago, that meant client-server applications hosted on dedicated hardware.
Today, we find ourselves in the midst of one of the biggest paradigm shifts in the industry: the move to cloud computing. Such transformations bring new opportunities for businesses but can be tricky for existing platforms, as they need to adapt to often different requirements imposed by the new kinds of applications that developers want to write.
The .NET platform has transitioned quite successfully, and I think one of the main reasons is that we designed it carefully and deliberately, focusing not only on productivity, consistency, and simplicity, but also on making sure that it can evolve over time..NET Core represents such evolution with 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.
Scott Guthrie
Redmond, WA
January 2020
Foreword to the Second Edition
When the .NET Framework was first published, I was fascinated by the technology. The benefits of the CLR (Common Language Runtime), its extensive APIs, and the C# language were immediately obvious. But underneath all the technology were a common design for the APIs and a set of conventions that were used everywhere. This was the .NET culture. Once you had learned a part of it, it was easy to translate this knowledge into other areas of the framework.
For the past 16 years, I have been working on open source software. Since contributors span not only multiple backgrounds but also multiple years, adhering to the same style and coding conventions has always been very important. Maintainers routinely rewrite or adapt contributions to software to ensure that code adheres to project coding standards and style. It is always better when contributors and people who join a software project follow conventions used in an existing project. The more information that can be conveyed through practices and standards, the simpler it becomes for future contributors to get up-to-speed on a project. This helps the project converge code, both old and new.