FrameworkDesignGuidelines2e.pdf
Framework Design Guidelines 2e.pdfC# 框架 设计规范Many of the designations used by manufacturers: Litrary of Congress Cataloging-in-Puublicnt ion Dataand sellers to distinguish their products are claimedCwalina, Krzysztofas trademarks. Where those designations appear inFramework design guidelines: conventionsthis book, and the publisher was aware of a tradeidioms, and patterns for reusable, NET libraries/mark claim, the designations have been printedwith initial capital letters or in all capitalsKrzysztof Cwalina, Brad Abrams. -2nd edPcImLThe NET_ logo is either a registered trademark orIncludes bibliographical references and indextrademark of Microsoft Corporation in the United ISBN 978-0-321-54561-9(hardcover: alk. paperStates and or other countries and is used under1. Microsoft. NET Framework. 2. Applicationlicense from microsoftprogram inter faces(Computer software)IAbrams, Brad. II. Title.Microsoft windows, visual basic visual c# andVisual C++ are either registered trademarks orQA76.76M52C8720080067882dc22trademarks of Microsoft Corporation in the US.A2008034905and/or other countries/regions.The authors and publisher have taken care in theCopyright o 2009 Microsoft Corporationpreparation of this book, but make no expressed orimplied warranty of any kind and assume: noAll rights reserved, Printed in the United States ofresponsibility for errors or omissions. No liability iAmerica. This publication is protected by copy-right, and permission must be obtained from theassumed forincidental or consequential damages in publisher prior to any prohibited reproduction,connection with or arising out of the use of the infor-storage in a retrieval system, or transmission in anymation or programs contained hereinform or by any means, electronic, mechanical, phoThe publisher offers excellent discounts on this bookcop ying, recording, or likewise. For informationwhen ordered in quantity for bulk purchases or spe-regarding permissions, write to:cial sales, which may include electronic versionsand /or custom covers 'and content particular to yourPearson Education. Inc.business, training goals, marketing focus, and brandRights and Contracts Department501 Boylston Street, Suite 900ing interests. For more information, please contact:Boston ma o2116U.S. Corporate and Government SalesFax(617)6713447(80)382-3419SBN-13:9780-321-54561-9corpsalesepearsontechgroup.comlsBN10:0321-54561-3For sales outside the United States please contactext printed in the United States on recycled paperInternational saleat Donnelley in Crawfordsville, IndianaFirst printing, October 2008international@pearson.comVisit uis on the Web: informit. com /awTo my woife, Elafor her support throughout the long process of writing this book,and to my parents,Jadwiga and Janusz, for their encouragement-Krzysztof CwvalinaTo my wife, TamaraYour love and patience strengthen meBrad abramsPraise for Framework Design GuidelinesFramework Design Guidelines is one of those rare books that can be read at different reading levels and can be useful to different kinds of developers. Regardlessof whether you want to design an effective object model, improve your under-standing of the NET Framework, borrow from the experience of softwaregurus, stay clear of the most common programming mistakes, or just get anidea of the huge effort that led to the. NET initiative, this book is a must-read.francescoBalena,TheVbMigrationPartnerTeam(www.vbmigration.com),Code architect. author and microsoft regional director italFrameworks are valuable but notoriously difficult to construct: your everdecision must be geared toward making them easy to be used correctly anddifficult to be used incorrectly. This book takes you through a progression ofrecommendations that will eliminate many of those downstream ' I wish I'dknown that earlier' moments I wish I'd read it earlier-Paul Besly, Principal Technologist, QANot since Brooks The Mythical Man Month has the major software maker ofits time produced a book so full of relevant advice for the modern softwaredeveloper. This book has a permanent place on my bookshelf and I consult itfrequently.-George Byrkit, Senior Software Engineer, Genomic SolutionsUpdated for the new language features of the. NET Framework 3.0 and 3.5,this book continues to be the definitive resource for. NET developers andrchitects who are designing class library frameworks. Some of the existinguidelines have been expanded with new annotations and more detail, andnew guidance covering such features as extension methods and nullabletypes has also been included. The guidance will help any developer writeleaner and more understandable code, while the annotations provide invaluable insight into some of the design decisions that made the NET Frameworkwhat it is today.-Scott dorman, Microsoft mvp and presidentTampa Bay International Association of Software ArchitectsFilled with information useful to developers and architects of all levels, thisbook provides practical guidelines and expert background information toget behind the rules Framework Design Guidelines takes the already pubshedguidelines to a higher level, and it is needed to write applicationsthat integrate well in the net area-Cristof falk, software engineerThis book is an absolute must read for all NET developers. It giIves clealand don't guidance on how to design class libraries for NET. It also offersinsight into the design and creation of NET that really helps developers understand the reasons why things are the way they are. This information will aiddevelopers designing their own class libraries and will also allow them to takeadvantage of the neT class library more effectively.-Jeffrey Richter, Author/ Trainer/Consultant, WintellectThe second edition of Framework Design Guidelines gives you new, importantinsight into designing your own class libraries: Abrams and Cwalina franklydiscuss the challenges of adding new features to shipping versions of their products with minimal impact on existing code. You'll find great examples of how tocreateversion N+l ofyour software by learning how the NET class library teamcreated versions 2.0, 3.0, and 3.5 of the NET library. They were able to add generics, WCE, WPF, WE, and LINQ with minimal impact on the existing APIs, evenproviding capabilities for customers wanting to use only some of the new features, while still maintaining compatibility with the original library.-Bill wagner founder and consultant. SRT Solutionsauthor of Effective C# and More Effective C#This book is a must read for all architects and software developers thinkiabout frameworks. The book offers insight into some driving factors behindthe design of the NET Framework. It should be considered mandatory readingfor anybody tasked with creating application frameworks- Peter Winkler, Sr Software Engineer, Balance Technology IncMicrosoft. NET Development SeriesJohn Montgomery, Series AdvisorDon Box, Series advisorBrad Abrams, Series AdvisorThe award-winning Microsoft. NET Development Series was established in 2002 to provide professionaldevelopers with the most comprehensive and practical coverage of the latest NET technologies. It issupported and developed by the leaders and experts of Microsoft development technologies, includingMicrosoft architects, MVPs, and leading industry luminaries. Books in this series provide a core resource ofinformation and understanding every developer needs to write effective applicationsTitles in the seriesBrad Abrams, NET Fnnezork Standard LibrartJames S. Miller and Susann RagsdaleAnnotated Reference Volume 1: Base Class Library andThe ComImon Language Infrastricture Annotated Standard,Extended numerics Libran, 978-0-321-15489-7978-0-321-15493-4Brad Abrams and Tamara Abrams, NET frameworkChristian Nagel, Enterprise Services with fhe. NETStandand Library Armotated Reference, Volume 2:Framework: Developing Distributed Business SolutionNetworking Library, Reflection Library, and XML Librarywith NET Enterprise Services, 978-0-321-24673-8978-0-321-19445-9Brian Noyes, Data Bindiug with Windows Forms 2.0Chris anderson essential Windows presentation foundationProgramming Smart Client Data Applications wifi NET,(wPF),978-0-321-37447-9978-0-321-26892-1Bob Beauchemin and Dan Sullivan, A Deteloper's Guide fo Brian Noyes, Smart Client Deployment with ClickOnceSOL Server2005,978-0-321-38218-4Deploying Windows Forms Applications with ClickOnceAdam Calderon, Joel Rumerman, Adzriced ASPNET9780-321-197696AJAX Server Controls: For. NET FrameWork 3.5Fritz Onion with Keith brown. Essential ASPNET 2.0978-0-321-51444-8978-0-321-237705Eric Carter and Eric Lippert, Visual Studio Tools for OficeSteve resnick. Richard Crane. Chris bowen. essentialLIsing C# eith Excel, Word, Outlook, and InfoPath,Windenes cOmmunication foundation: For Net framework9780-321-334B8635,9780-321-44006-8Eric Carter and Eric Lippert, Visial Stud io Tools forScott Roberts and Hagen Green, Designing FormsOffice: Llsing Visual Basic 2005 with Excel, Word, Outlook,for Microsoft Office info Path and Forts Services 2007and InfoPath,978-0-321-41175-4978-0-321410597Steve Cook, Gareth Jones, Stuart Kent: Alan CameronWills, Domain-Specific Development woith Visual StudioNeil Roodyn, e Xtreme. NET: Introducing e XtremeProgramming Techniques to NET DeveloppersDsL Tools,978-0-321-39820-8978-0-321-303639Krzysztof Cwalina and Brad Abrams, Framework DesignChris sells and michael weinhardt. wiudozus fornis 2.0Guidelines: Contentions, Idioms, and Patterns for ReusableNET Libraries, second edition 978-01-321-54561-9Prwi,978321-26796-2Joe Dufty, Concurrent Programming on Windows,Dharma Shuikla and Bob Schmidt, Essential Windows978-0-321-434821Workflow Fotnrdatiot, 978-0-321-39983-0Sam Guckenheimer and Juan J. Perez, SoftwareGuy Snith-Ferrier,. NE T InternationalizfioirEngineering with Microsoft Visual Studio Team System,The Derxeloper's Guide to Building globl Windows9780-321-278722and Web applications, 978-0-321-34138-9Anders Hejlsberg, Mads Torgersen, Scott Wiltamuth,Will Stott and James Newkirk, Visual Studio TeaPeter Golde, The C# Programming Language, Third EditionSystem: Better Softamre Development for Agile Teams978-0=321562999078-0-321-41850-0Alex homer and daye sussman aspnet 2o lustratedPaul Yao and David Durant, NET Compct Framework978-0-321-41834-0Prograrmning woith C#, 978-0-321-17403-1Joe Kaplan and Ryan Dunn, The. NET Deureloper's Guide toPaul Yao and David Durant, NET Compact FrameworkDirectory Services Programining, 978-0-321-35017-6Programming reith Visial Basic, NET, 978-0-321-17404-gMark michaelis. essential c 3, 0: For Net framework 3 5978-0-321-53302For more information go to informit. com/msdotnetseriesFiguresFIGURE 2-1: Learning curve of a mnltiframework platform 12FIGURE 2-2: Learning curve of a progressive framework platform 13FIGURE 4-1: The logical grouping of types 77FIGURE 9-1: Query Pattern Method Signatures 341XVIITablesTABLE 3-1: Capitalization Rules for Different Types of Identifiers 40TABLE 3-2: Capitalization and Spelling for Common CompoundWords ard Commmon Terns 43TABLE 3-3: CLR Type Names for Language-Specific Type Names 50TABLE 3-4: Name Riles for Types Derived from or ImplementingCertain Core Types 65TABLE 5-1: Operators and Correspording Method Names 172TABLE 8.1: NET Framework Serialization Technologies 274TABLE B. 1: Suffixes for Common Base Types and Interfaces 379TABLE B, 2: Symmetric Operators 392XIXForewordWhen the. NET Framework was first published, I was fascinated by thetechnology. The benefits of the CLR( Common Language Runtime), itsextensive APls, and the C# language were immediately obvious. Butunderneath all the technology were a common design for the APIs and aset of conventions that were used everywhere. This was the. NET cultureOnce you had learned a part of it, it was easy to translate this knowledgeinto other areas of the FrameworkFor the past 16 years, I have been working on open source softwareSince contributors span not only multiple backgrounds but multiple years,adhering to the same style and coding conventions has always been veryimportant Maintainers routinely rewrite or adapt contributions to software to ensure that code adheres to project coding standards and style. Itis always better when contributors and people who join a software projectfollow conventions used in an existing project. The more information thatcan be conveyed through practices and standards, the simpler it becomesfor future contributors to get up-to-speed on a project. This helps the project converge code. both old and new,As both the. NET Framework and its developer community havegrown, new practices, patterns, and conventions have been identified.Brad and Krzysztof have become the curators who turned all of this newknowledge into the present-day guidelines. They typically blog about anew convention, solicit feedback from the community, and keep track of
下载地址
用户评论