.NET设计规范——约定、惯用法与模式(第2版·英文版)(附光盘)(图灵程序设计丛书·微软技术系列)(Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, Second E)
分類: 图书,计算机与互联网,程序语言与软件开发,语言与开发工具,.net,
品牌: Krzysztof Cwalina
基本信息·出版社:人民邮电出版社
·出版日期:2010年01月
·ISBN:9787115214454
·条形码:9787115214454
·版本:第1版
·装帧:平装
·开本:16
·正文语种:英语
·丛书名:图灵程序设计丛书·微软技术系列
·外文书名:Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, Second E
产品信息有问题吗?请帮我们更新产品信息。
内容简介本书关注直接影响框架可编程能力的设计问题,为框架设计师和广大开发人员设计高质量的软件提供了权威的指南,这一版更新至.NET 3.5。书中内容涉及框架设计的基本原则和规范,常用设计惯用法,为命名空间、类型、成员等框架各部分命名的规范,框架中常用设计模式的规范等。同时,书中添加了来自经验丰富的框架设计师、业界专家及用户给出的评注,为书中的许多规范增色不少。
本书为框架设计师必读之作,也可用作.NET开发人员的技术参考书。
目录
Contents
1Introduction1
1.1Qualities of a Well-Designed Framework3
1.1.1Well-Designed Frameworks Are Simple3
1.1.2Well-Designed Frameworks Are Expensive to Design4
1.1.3Well-Designed Frameworks Are Full of Trade-Offs5
1.1.4Well-Designed Frameworks Borrow from the Past5
1.1.5Well-Designed Frameworks Are Designed to Evolve5
1.1.6Well-Designed Frameworks Are Integrated6
1.1.7Well-Designed Frameworks Are Consistent6
2Framework Design Fundamentals9
2.1Progressive Frameworks11
2.2Fundamental Principles of Framework Design14
2.2.1The Principle of Scenario-Driven Design15
2.2.2The Principle of Low Barrier to Entry21
2.2.3The Principle of Self-Documenting Object Models26
2.2.4The Principle of Layered Architecture33
3Naming Guidelines37
3.1Capitalization Conventions38
3.1.1Capitalization Rules for Identifiers38
3.1.2Capitalizing Acronyms40
3.1.3Capitalizing Compound Words and Common Terms43
3.1.4Case Sensitivity45
3.2General Naming Conventions46
3.2.1WordChoice46
3.2.2Using Abbreviations and Acronyms48
3.2.3Avoiding Language-Specific Names49
3.2.4Naming New Versions of Existing APIs51
3.3Names of Assemblies and DLLs54
3.4Names of Namespaces56
3.4.1Namespaces and Type Name Conflicts58
3.5Names of Classes, Structs, and Interfaces60
3.5.1Names of Generic Type Parameters64
3.5.2Names of Common Types64
3.5.3Naming Enumerations66
3.6Names of Type Members68
3.6.1Names of Methods68
3.6.2Names of Properties68
3.6.3Names of Events70
3.6.4Naming Fields72
3.7Naming Parameters73
3.7.1Naming Operator Overload Parameters74
3.8Naming Resources74
4Type Design Guidelines77
4.1 Types and Namespaces79
4.1.1Standard Subnamespace Names83
4.2Choosing Between Class and Struct84
4.3Choosing Between Class and Interface88
4.4Abstract Class Design95
4.5Static Class Design97
4.6Interface Design98
4.7Struct Design101
4.8EnumDesign103
4.8.1Designing Flag Enums110
4.8.2Adding Values to Enums114
4.9Nested Types115
4.10Types and Assembly Metadata118
5MemberDesign121
5.1General Member Design Guidelines121
5.1.1Member Overloading121
5.1.2Implementing Interface Members Explicitly128
5.1.3Choosing Between Properties and Methods132
5.2Property Design138
5.2.1Indexed Property Design140
5.2.2Property Change Notification Events142
5.3Constructor Design144
5.3.1Type Constructor Guidelines151
5.4Event Design153
5.4.1Custom Event Handler Design159
5.5Field Design159
5.6Extension Methods162
5.7Operator Overloads168
5.7.1Overloading Operator ==173
5.7.2Conversion Operators173
5.8Parameter Design175
5.8.1Choosing Between Enum and Boolean Parameters177
5.8.2Validating Arguments179
5.8.3Parameter Passing183
5.8.4Members with Variable Number of Parameters186
5.8.5Pointer Parameters190
6Designing for Extensibility193
6.1Extensibility Mechanisms193
6.1.1Unsealed Classes194
6.1.2Protected Members196
6.1.3Events and Callbacks197
6.1.4Virtual Members201
6.1.5Abstractions (Abstract Types and Interfaces)203
6.2Base Classes206
6.3Sealing207
7Exceptions211
7.1Exception Throwing216
7.2Choosing the Right Type of Exception to Throw221
7.2.1Error Message Design225
7.2.2Exception Handling227
7.2.3Wrapping Exceptions232
7.3Using Standard Exception Types234
7.3.1ExceptCon and SystemException234
7.3.2ApplicationException234
7.3.3InvalidOperationExceptCon235
7.3.4ArgumentException, ArgumentNullException, and ArgumentOutOfRangeException235
7.3.5NullReferenceException, IndexOutOfRangeException, and AccessViolationException237
7.3.6StackOverflowException237
7.3.70utOfMemoryException238
7.3.8ComException, SEHException, and ExecutionEngineException239
7.4Designing Custom Exceptions239
7.5Exceptions and Performance240
7.5.1Tester-Doer Pattern241
7.5.2Try-Parse Pattern242
8Usage Guidelines245
8.1Arrays245
8.2Attributes247
8.3Collections250
8.3.1Collection Parameters252
8.3.2Collection Properties and Return Values253
8.3.3Choosing Between Arrays and Collections258
8.3.4Implementing Custom Collections259
8.4DateTime and DateTimeOffset261
8.5ICloneable263
8.6IComparableand IEquatable264
8.7IDisposable266
8.8Nuiiable266
8.9Object268
8.9.1Object.EquaLs268
8.9.2Object.GetHashCode270
8.9.3Object.ToStrlng271
8.10Serialization274
8.10.1Choosing the Right Serialization Technology to Support275
8.10.2Supporting Data Contract Serialization276
8.10.3Supporting XML Serialization280
8.10.4Supporting Runtime Serialization281
8.11UrL 283
8.11.1System. Uri Implementation Guidelines284
8,12System.Xml Usage284
8.13Equality Operators286
8.13.1Equality Operators on Value Types287
8.13.2Equality Operators on Reference Types287
9Common Design Patterns289
9.1Aggregate Components289
9.1.1Component-Oriented Design291
9.1.2FactoredTypes294
9.1.3Aggregate Component Guidelines295
9.2The Async Patterns298
9.2.1Choosing Between the Async Patterns298
9.2.2Classic Async Pattern300
9.2.3Classic Async Pattern Basic Implementation Example304
9.2.4Event-Based Async Pattern305
9.2.5Supporting Out and Ref Parameters307
9.2.6Supporting Cancellation308
9.2.7Supporting Progress Reporting309
9.2.8Supporting Incremental Results311
9.3Dependency Properties312
9.3.1Dependency Property Design313
9.3.2Attached Dependency Property Design315
9.3.3Dependency Property Validation316
9.3.4Dependency Property Change Notifications317
9.3.5Dependency Property Value Coercion318
9.4Dispose Pattern319
9.4.1Basic Dispose Pattern322
9.4.2Finalizable Types328
9.5Factories332
9.6LINQ Support337
9.6.1Overview of LINQ337
9.6.2Ways of Implementing LINQ Support339
9.6.3Supporting LINQ through IEnumerabLe339
9.6.4Supporting LINQ through IOueryabLe340
9.6.5Supporting LINQ through the Query Pattern341
9.7Optional Feature Pattern344
9.8Simulating Covariance348
9.9Template Method354
9.10Timeouts356
9.11XAML Readable Types358
9.12And in the End...361
AC# Coding Style Conventions363
A.1General Style Conventions364
A.1.1Brace Usage364
A.1.2Space Usage365
A.1.3Indent Usage367
A.1.4Other 367
A.2Naming Conventions367
A.3Comments368
A.4File Organization369
BUsing FxCop to Enforce the Framework Design Guidelines371
B.1What Is FxCop?371
B.2The Evolution of FxCop372
B.3How Does It Work?373
B.4FxCop Guideline Coverage374
B.4.1FxCop Rules for the Naming Guidelines374
B.4.2FxCop Rules for the Type Design Guidelines384
B.4.3FxCop Rules for Member Design387
B.4.4FxCop Rules for Designing for Extensibility394
B.4,5FxCop Rules for Exceptions395
B.4.6FxCop Rules for Usage Guidelines397
B.4.7FxCop Rules for Design Patterns402
CSample API Specification405
Glossary413
Suggested Reading List419
Index423
……[看更多目录]