出版時間:2010-1 出版社:人民郵電出版社 作者:Krzysztof Cwalina,,Brad Abrams 頁數:443
Tag標簽:無
前言
.NET Framework一推出,我就立即對它著了迷。這種技術讓CLR(通用語言運行庫)及其大量API,以及C#語言的優(yōu)勢立刻彰顯無遺。這些技術無不體現了API的通用設計風格和始終貫徹的一系列約定。這就是.NET文化。一旦你了解了這種文化,就容易把有關知識運用到框架設計的其他領域中去。過去16年里,我一直在從事開源軟件工作。由于開源的特點,開發(fā)者不僅文化背景不同,連開發(fā)時間也會跨越好幾年,這時堅守一種風格和編碼約定就顯得特別重要。雖然我們有維護人員,其日常的工作就是重寫或修改提交來的軟件,保證代碼遵守項目編碼標準和風格,但是,如果參與軟件項目的所有人一開始就使用項目的約定,當然就更為理想。通過實踐和標準所傳達出的信息越多,未來新加入的人員就越容易上手。這有利于項目匯聚和融合新老代碼。.NET Framework在成長,其開發(fā)者社區(qū)也在成長,人們不斷確定了新的實踐、模式和約定。Brad和Krzysztof挺身而出,成為了這些規(guī)則的“監(jiān)護人”,他們把這些新知識轉變?yōu)楝F在這本規(guī)范。他們通常會在博客里介紹新的約定,收集社區(qū)的反饋,再記錄下這些規(guī)范。在我看來,任何人若有興趣用好.NET Framework,則必須要常看他們的博客。這本書第1版出版以后,立即成為整個:Motto社區(qū)傳誦的經典,其原因大體有兩個。首先,我們可以由此了解各種.NET API實現的原委和方式;其次,我們珍視其為無價的規(guī)范,也努力貫徹在自己的程序和庫的設計過程中。第2版不僅建立在第1版成功的基礎之上,而且還添加了不少新的知識。許多規(guī)范還增加了注解,注解者本身就是行業(yè)里首屈一指的.NET架構師和偉大的程序員,正是他們幫助確定了這些規(guī)范。最后我要說,這本書遠不止是一本規(guī)范。它是我們熱愛的一部經典,可以幫助我們成為一名杰出的程序員,而這樣的程序員在我們行業(yè)里現在還為數不多。
內容概要
本書關注直接影響框架可編程能力的設計問題,為框架設計師和廣大開發(fā)人員設計高質量的軟件提供了權威的指南,這一版更新至.NET 3.5。書中內容涉及框架設計的基本原則和規(guī)范,常用設計慣用法,為命名空間、類型、成員等框架各部分命名的規(guī)范,框架中常用設計模式的規(guī)范等。同時,書中添加了來自經驗豐富的框架設計師、業(yè)界專家及用戶給出的評注,為書中的許多規(guī)范增色不少。 本書為框架設計師必讀之作,也可用作.NET開發(fā)人員的技術參考書。
作者簡介
作者:(美國)克瓦琳娜(Krzysztof Cwalina) (美國)艾布拉姆斯(Brad Abrams)克瓦琳娜(Krzysztof Cwalina),微軟公司.NET Franmwork開發(fā)組項目經理。他為.NET Framework設計了多個API。還開發(fā)了FxCop等框架開發(fā)工具。目前,他正致力于在微軟內部開發(fā)推廣設計規(guī)范。將其應用到.NET Framework中。同時負責核心.NET Framework API的交付。艾布拉姆斯(Brad Abrams),微軟公司CLR開發(fā)組和.NET Framework開發(fā)組的創(chuàng)始人之一,目前是項目經理主管。他參與制定了CLS、.NET Framework設計規(guī)范以及ECMA/ISOCLI標準中程序庫標準。著有Programming in the.NET Environment、.NET Framework StandardLibrary Annotated Reference(卷1和卷2)等書。讀者可以從他的博客http://blogs.msdn.com/bradA/中了解他的最新想法。
書籍目錄
1 Introduction 1.1 Qualities of a Well-Designed Framework 1.1.1 Well-Designed Frameworks Are Simple 1.1.2 Well-Designed Frameworks Are Expensive to Design 1.1.3 Well-Designed Frameworks Are Full of Trade-Offs 1.1.4 Well-Designed Frameworks Borrow from the Past 1.1.5 Well-Designed Frameworks Are Designed to Evolve 1.1.6 Well-Designed Frameworks Are Integrated 1.1.7 Well-Designed Frameworks Are Consistent 2 Framework Design Fundamentals 2.1 Progressive Frameworks 2.2 Fundamental Principles of Framework Design 2.2.1 The Principle of Scenario-Driven Design 2.2.2 The Principle of Low Barrier to Entry 2.2.3 The Principle of Self-Documenting Object Models 2.2.4 The Principle of Layered Architecture 3 Naming Guidelines 3.1 Capitalization Conventions 3.1.1 Capitalization Rules for Identifiers 3.1.2 Capitalizing Acronyms 3.1.3 Capitalizing Compound Words and Common Terms 3.1.4 Case Sensitivity 3.2 General Naming Conventions 3.2.1 WordChoice 3.2.2 Using Abbreviations and Acronyms 3.2.3 Avoiding Language-Specific Names 3.2.4 Naming New Versions of Existing APIs 3.3 Names of Assemblies and DLLs 3.4 Names of Namespaces 3.4.1 Namespaces and Type Name Conflicts 3.5 Names of Classes, Structs, and Interfaces 3.5.1 Names of Generic Type Parameters 3.5.2 Names of Common Types 3.5.3 Naming Enumerations 3.6 Names of Type Members 3.6.1 Names of Methods 3.6.2 Names of Properties 3.6.3 Names of Events 3.6.4 Naming Fields 3.7 Naming Parameters 3.7.1 Naming Operator Overload Parameters 3.8 Naming Resources 4 Type Design Guidelines 4.1 Types and Namespaces 4.1.1 Standard Subnamespace Names 4.2 Choosing Between Class and Struct 4.3 Choosing Between Class and Interface 4.4 Abstract Class Design 4.5 Static Class Design 4.6 Interface Design 4.7 Struct Design 4.8 EnumDesign 4.8.1 Designing Flag Enums 4.8.2 Adding Values to Enums 4.9 Nested Types 4.10 Types and Assembly Metadata 5 MemberDesign 5.1 General Member Design Guidelines 5.1.1 Member Overloading 5.1.2 Implementing Interface Members Explicitly 5.1.3 Choosing Between Properties and Methods 5.2 Property Design 5.2.1 Indexed Property Design 5.2.2 Property Change Notification Events 5.3 Constructor Design 5.3.1 Type Constructor Guidelines 5.4 Event Design 5.4.1 Custom Event Handler Design 5.5 Field Design 5.6 Extension Methods 5.7 Operator Overloads 5.7.1 Overloading Operator == 5.7.2 Conversion Operators 5.8 Parameter Design 5.8.1 Choosing Between Enum and Boolean Parameters 5.8.2 Validating Arguments 5.8.3 Parameter Passing 5.8.4 Members with Variable Number of Parameters 5.8.5 Pointer Parameters 6 Designing for Extensibility 6.1 Extensibility Mechanisms 6.1.1 Unsealed Classes 6.1.2 Protected Members 6.1.3 Events and Callbacks 6.1.4 Virtual Members 6.1.5 Abstractions (Abstract Types and Interfaces) 6.2 Base Classes 6.3 Sealing 7 Exceptions 7.1 Exception Throwing 7.2 Choosing the Right Type of Exception to Throw 7.2.1 Error Message Design 7.2.2 Exception Handling 7.2.3 Wrapping Exceptions 7.3 Using Standard Exception Types 7.3.1 ExceptCon and SystemExcept~on 7.3.2 AppL ~cat~onExcept~on 7.3.3 InvaL ~dOperat~onExceptCon 7.3.4 ArgumentExcept~on, ArgumentNuL LExcept~on, and ArgumentOutOfRangeExcept~on 7.3.5 NuL LReferenceExcept~on, IndexOutOfRangeExcept~on, and AccessVCoLatConExcept~on 7.3.6 StackOverfLowExcept~on 7.3.7 utOfMemoryExcept~on 7.3.8 ComExcept~on, SEHExceptCon, and Execut~onEng~ne-Exception 7.4 Designing Custom Exceptions 7.5 Exceptions and Performance 7.5.1 Tester-Doer Pattern 7.5.2 Try-Parse Pattern 8 Usage Guidelines 8.1 Arrays 8.2 Attributes 8.3 Collections 8.3.1 Collection Parameters 8.3.2 Collection Properties and Return Values 8.3.3 Choosing Between Arrays and Collections 8.3.4 Implementing Custom Collections 8.4 DateTime and DateTimeOffset 8.5 ICloneable 8.6 IComparable and IEquatable 8.7 IDisposable 8.8 Nuiiable 8.9 Object 8.9.1 Object. EquaLs 8.9.2 Object. GetHashCode 8.9.3 Object. ToStrlng271 8.10 Serialization 8.10.1 Choosing the Right Serialization Technology to Support 8.10.2 Supporting Data Contract Serialization 8.10.3 Supporting XML Serialization 8.10.4 Supporting Runtime Serialization 8.11 UrL 283 8.11.1 System. Urn. Implementation Guidelines 8.12 System.Xml Usage 8.13 Equality Operators 8.13.1 Equality Operators on Value Types 8.13.2 Equality Operators on Reference Types 9 Common Design Patterns 9.1 Aggregate Components 9.1.1 Component-Oriented Design 9.1.2 FactoredTypes 9.1.3 Aggregate Component Guidelines 9.2 The Async Patterns 9.2.1 Choosing Between the Async Patterns 9.2.2 Classic Async Pattern 9.2.3 Classic Async Pattern Basic Implementation Example 9.2.4 Event-Based Async Pattern 9.2.5 Supporting Out and Ref Parameters 9.2.6 Supporting Cancellation 9.2.7 Supporting Progress Reporting 9.2.8 Supporting Incremental Results 9.3 Dependency Properties 9.3.1 Dependency Property Design 9.3.2 Attached Dependency Property Design 9.3.3 Dependency Property Validation 9.3.4 Dependency Property Change Notifications 9.3.5 Dependency Property Value Coercion 9.4 Dispose Pattern 9.4.1 Basic Dispose Pattern 9.4.2 Finalizable Types 9.5 Factories 9.6 LINQ Support 9.6.1 Overview of LINQ 9.6.2 Ways of Implementing LINQ Support 9.6.3 Supporting LINQ through IEnumerabLe 9.6.4 Supporting LINQ through IOueryabLe~T~ 9.6.5 Supporting LINQ through the Query Pattern 9.7 Optional Feature Pattern 9.8 Simulating Covariance 9.9 Template Method 9.10 Timeouts 9.11 XAML Readable Types 9.12 And in the End... A C# Coding Style Conventions A.1 General Style Conventions A.1.1 Brace Usage A.1.2 Space Usage A.1.3 Indent Usage A.1.4 Other 367 A.2 Naming Conventions A.3 Comments A.4 File Organization B Using FxCop to Enforce the Framework Design Guidelines B.1 What Is FxCop? B.2 The Evolution of FxCop B.3 How Does It Work? B.4 FxCop Guideline Coverage B.4.1 FxCop Rules for the Naming Guidelines B.4.2 FxCop Rules for the Type Design Guidelines B.4.3 FxCop Rules for Member Design B.4.4 FxCop Rules for Designing for Extensibility B.4.5 FxCop Rules for Exceptions B.4.6 FxCop Rules for Usage Guidelines B.4.7 FxCop Rules for Design Patterns C Sample API Specification Glossary Suggested Reading List Index
章節(jié)摘錄
插圖:F YOU COULD STAND over the shoulder of every developer who is using your framework to write code and explain how it is supposea tobe used, guidelines would not be necessary. The guidelines presented inthis book give you, as the framework author, a palette o{ tools that allowyou to create a common language between framework authors and thedevelopers who will use the frameworks. For example, exposing an opera-tion as a property instead of exposing it as a method conveys vital infor-mation about how that operation is to be used.In the early days of the PC era, the main tools for developing applica-tions were a programming language compiler, a very small set of standardlibraries, and the raw operating system application programming inter-faces (APIs)-a very basic set of low-level programming tools.Even as developers were building applications using such basic tools,they were discovering an increasing amount of code that was repetitiveand could be abstracted away through higher-level APIs. Operating sys-tem vendors noticed that they could make it cheaper for developers tocreate applications for their systems if they provided them with suchhigher-level APIs. The number of applications that could run on the sys-tem would increase, which would then make the system more appealingto end users who demanded a variety of applications. Also, independenttool and component vendors quickly recognized the business opportuni-ties offered by raising the API abstraction level.
媒體關注與評論
“本書第1版出版以后.立即成為整個Mono社區(qū)傳誦的經典……這一版彌補了上一版的很多不足。而眾多參與規(guī)范制定的核心.NET架構師及頂尖程序員所做的評注也極大地豐富了本書的內涵?!薄 狹iguel de Icaza.GNOME和Mono項目創(chuàng)建者“本書絕對是所有.NET開發(fā)人員的必讀之作。它總結了.NET本身設計和開發(fā)過程中獲得的經驗和教訓。不僅使你對.NET能夠知其所以然。還能極大地幫助你更高效地使用.NET類庫?!薄 狫effrey Richter,微軟技術大師,名著《Windows核心編程》作者
編輯推薦
《.NET設計規(guī)范:約定、慣用法與模式(第2版·英文版)》:數千名微軟精銳開發(fā)人員的經驗和智慧。最終濃縮在這本設計規(guī)范之中。與上一版相比。書中新增了許多評注。解釋了相應規(guī)范的背景和歷史,從中你能聆聽到微軟技術大師Andem Hejlsberg、Jeffrey Richter和Paul Vick等的聲音。讀來令人興趣盎然.欲罷不能?!?NET設計規(guī)范:約定、慣用法與模式(第2版·英文版)》雖然是針對.NET平臺上的框架設計的。但對其他平臺的框架設計同樣具有借鑒意義。新版根據.NET Framework 3.0和3.5的新特性做了全面更新,主要關注的是直接影響框架可編程能力的設計問題。遵守這些規(guī)范對于使用.NET Framework創(chuàng)建高質量的應用程序至關重要。微軟.N ET Framework設計組的智慧結晶洞悉.NET技術內幕.N ET開發(fā)者的必備圖書《.NET設計規(guī)范:約定、慣用法與模式(第2版·英文版)》提供配套光盤。內含Designing.NET Class Librarides等13個演講視頻(時長近13小時)。此外.光盤還包括.NETFramework類和組件設計指南、API規(guī)范樣例以及其他有用的資源和工具。
圖書封面
圖書標簽Tags
無
評論、評分、閱讀與下載