.NET设计规范——约定、惯用法与模式(第2版·英文版)(附光盘)
分類: 图书,计算机/网络,程序设计,.NET ,
作者: (美)克瓦林纳,(美)艾布拉姆斯著
出 版 社: 人民邮电出版社
出版时间: 2010-1-1字数: 557000版次: 1页数: 443印刷时间: 2010-1-1开本: 16开印次: 1纸张: 胶版纸I S B N : 9787115214454包装: 平装内容简介
本书关注直接影响框架可编程能力的设计问题,为框架设计师和广大开发人员设计高质量的软件提供了权威的指南,这一版更新至.NET 3.5。书中内容涉及框架设计的基本原则和规范,常用设计惯用法,为命名空间、类型、成员等框架各部分命名的规范,框架中常用设计模式的规范等。同时,书中添加了来自经验丰富的框架设计师、业界专家及用户给出的评注,为书中的许多规范增色不少。
本书为框架设计师必读之作,也可用作.NET开发人员的技术参考书。
目录
1Introduction
1.1Qualities of a Well-Designed Framework
1.1.1Well-Designed Frameworks Are Simple
1.1.2Well-Designed Frameworks Are Expensive to Design
1.1.3Well-Designed Frameworks Are Full of Trade-Offs
1.1.4Well-Designed Frameworks Borrow from the Past
1.1.5Well-Designed Frameworks Are Designed to Evolve
1.1.6Well-Designed Frameworks Are Integrated
1.1.7Well-Designed Frameworks Are Consistent
2Framework Design Fundamentals
2.1Progressive Frameworks
2.2Fundamental Principles of Framework Design
2.2.1The Principle of Scenario-Driven Design
2.2.2The Principle of Low Barrier to Entry
2.2.3The Principle of Self-Documenting Object Models
2.2.4The Principle of Layered Architecture
3Naming Guidelines
3.1Capitalization Conventions
3.1.1Capitalization Rules for Identifiers
3.1.2Capitalizing Acronyms
3.1.3Capitalizing Compound Words and Common Terms
3.1.4Case Sensitivity
3.2General Naming Conventions
3.2.1WordChoice
3.2.2Using Abbreviations and Acronyms
3.2.3Avoiding Language-Specific Names
3.2.4Naming New Versions of Existing APIs
3.3Names of Assemblies and DLLs
3.4Names of Namespaces
3.4.1Namespaces and Type Name Conflicts
3.5Names of Classes, Structs, and Interfaces
3.5.1Names of Generic Type Parameters
3.5.2Names of Common Types
3.5.3Naming Enumerations
3.6Names of Type Members
3.6.1Names of Methods
3.6.2Names of Properties
3.6.3Names of Events
3.6.4Naming Fields
3.7Naming Parameters
3.7.1Naming Operator Overload Parameters
3.8Naming Resources
4Type Design Guidelines
4.1 Types and Namespaces
4.1.1Standard Subnamespace Names
4.2Choosing Between Class and Struct
4.3Choosing Between Class and Interface
4.4Abstract Class Design
4.5Static Class Design
4.6Interface Design
4.7Struct Design
4.8EnumDesign
4.8.1Designing Flag Enums
4.8.2Adding Values to Enums
4.9Nested Types
4.10Types and Assembly Metadata
5MemberDesign
5.1General Member Design Guidelines
5.1.1Member Overloading
5.1.2Implementing Interface Members Explicitly
5.1.3Choosing Between Properties and Methods
5.2Property Design
5.2.1Indexed Property Design
5.2.2Property Change Notification Events
5.3Constructor Design
5.3.1Type Constructor Guidelines
5.4Event Design
5.4.1Custom Event Handler Design
5.5Field Design
5.6Extension Methods
5.7Operator Overloads
5.7.1Overloading Operator ==
5.7.2Conversion Operators
5.8Parameter Design
5.8.1Choosing Between Enum and Boolean Parameters
5.8.2Validating Arguments
5.8.3Parameter Passing
5.8.4Members with Variable Number of Parameters
5.8.5Pointer Parameters
6Designing for Extensibility
6.1Extensibility Mechanisms
6.1.1Unsealed Classes
6.1.2Protected Members
6.1.3Events and Callbacks
6.1.4Virtual Members
6.1.5Abstractions (Abstract Types and Interfaces)
6.2Base Classes
6.3Sealing
7Exceptions
7.1Exception Throwing
7.2Choosing the Right Type of Exception to Throw
7.2.1Error Message Design
7.2.2Exception Handling
7.2.3Wrapping Exceptions
7.3Using Standard Exception Types
7.3.1ExceptCon and SystemExcept~on
7.3.2AppL ~cat~onExcept~on
7.3.3InvaL ~dOperat~onExceptCon
7.3.4ArgumentExcept~on, ArgumentNuL LExcept~on, and ArgumentOutOfRangeExcept~on
7.3.5NuL LReferenceExcept~on, IndexOutOfRangeExcept~on, and AccessVCoLatConExcept~on
7.3.6StackOverfLowExcept~on
7.3.7utOfMemoryExcept~on
7.3.8ComExcept~on, SEHExceptCon, and Execut~onEng~ne-Exception
7.4Designing Custom Exceptions
7.5Exceptions and Performance
7.5.1Tester-Doer Pattern
7.5.2Try-Parse Pattern
8Usage Guidelines
8.1Arrays
8.2Attributes
8.3Collections
8.3.1Collection Parameters
8.3.2Collection Properties and Return Values
8.3.3Choosing Between Arrays and Collections
8.3.4Implementing Custom Collections
8.4DateTime and DateTimeOffset
8.5ICloneable
8.6IComparableand IEquatable
8.7IDisposable
8.8Nuiiable
8.9Object
8.9.1Object. EquaLs
8.9.2Object. GetHashCode
8.9.3Object. ToStrlng271
8.10Serialization
8.10.1Choosing the Right Serialization Technology to Support
8.10.2Supporting Data Contract Serialization
8.10.3Supporting XML Serialization
8.10.4Supporting Runtime Serialization
8.11UrL 283
8.11.1System. Urn. Implementation Guidelines
8.12System.Xml Usage
8.13Equality Operators
8.13.1Equality Operators on Value Types
8.13.2Equality Operators on Reference Types
9Common Design Patterns
9.1Aggregate Components
9.1.1Component-Oriented Design
9.1.2FactoredTypes
9.1.3Aggregate Component Guidelines
9.2The Async Patterns
9.2.1Choosing Between the Async Patterns
9.2.2Classic Async Pattern
9.2.3Classic Async Pattern Basic Implementation Example
9.2.4Event-Based Async Pattern
9.2.5Supporting Out and Ref Parameters
9.2.6Supporting Cancellation
9.2.7Supporting Progress Reporting
9.2.8Supporting Incremental Results
9.3Dependency Properties
9.3.1Dependency Property Design
9.3.2Attached Dependency Property Design
9.3.3Dependency Property Validation
9.3.4Dependency Property Change Notifications
9.3.5Dependency Property Value Coercion
9.4Dispose Pattern
9.4.1Basic Dispose Pattern
9.4.2Finalizable Types
9.5Factories
9.6LINQ Support
9.6.1Overview of LINQ
9.6.2Ways of Implementing LINQ Support
9.6.3Supporting LINQ through IEnumerabLe
9.6.4Supporting LINQ through IOueryabLe~T~
9.6.5Supporting LINQ through the Query Pattern
9.7Optional Feature Pattern
9.8Simulating Covariance
9.9Template Method
9.10Timeouts
9.11XAML Readable Types
9.12And in the End...
AC# Coding Style Conventions
A.1General Style Conventions
A.1.1Brace Usage
A.1.2Space Usage
A.1.3Indent Usage
A.1.4Other 367
A.2Naming Conventions
A.3Comments
A.4File Organization
BUsing FxCop to Enforce the Framework Design Guidelines
B.1What Is FxCop?
B.2The Evolution of FxCop
B.3How Does It Work?
B.4FxCop Guideline Coverage
B.4.1FxCop Rules for the Naming Guidelines
B.4.2FxCop Rules for the Type Design Guidelines
B.4.3FxCop Rules for Member Design
B.4.4FxCop Rules for Designing for Extensibility
B.4.5FxCop Rules for Exceptions
B.4.6FxCop Rules for Usage Guidelines
B.4.7FxCop Rules for Design Patterns
CSample API Specification
Glossary
Suggested Reading List
Index