命名规则Naming Guidelines

在框架开发中遵循一套一致的命名约定可极大地提升框架的可用性。Following a consistent set of naming conventions in the development of a framework can be a major contribution to the framework’s usability. 通过这种方式,框架便可供许多开发人员广泛用于各种不同的项目。It allows the framework to be used by many developers on widely separated projects. 除了形式的一致性外,框架元素的名称必须易于理解,且须能够传达每个元素的功能。Beyond consistency of form, names of framework elements must be easily understood and must convey the function of each element.

本文的目的是提供一组一致的命名约定,用于生成便于开发人员理解和使用的名称。The goal of this chapter is to provide a consistent set of naming conventions that results in names that make immediate sense to developers.

虽然采用这些命名约定并将其用作常规代码开发准则,可以在整个代码中实现更一致的命名,但要求仅将其用于向公共领域公开的 API(公共或受保护的类型和成员以及显式实现的接口)。Although adopting these naming conventions as general code development guidelines would result in more consistent naming throughout your code, you are required only to apply them to APIs that are publicly exposed (public or protected types and members, and explicitly implemented interfaces).

本节内容In This Section

大小写约定Capitalization Conventions
通用命名约定General Naming Conventions
程序集和 DLL 的名称Names of Assemblies and DLLs
命名空间的名称Names of Namespaces
类、结构和接口的名称Names of Classes, Structs, and Interfaces
类型成员的名称Names of Type Members
命名参数Naming Parameters
命名资源Naming Resources
部分©2005,2009 Microsoft Corporation。保留所有权利。Portions © 2005, 2009 Microsoft Corporation. All rights reserved.

*在 Pearson Education, Inc. 授权下,由 Addison-Wesley Professional 作为 Microsoft Windows 开发系列的一部分再版自 Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition(Framework 设计准则:可重用 .NET 库的约定、惯例和模式第 2 版),由 Krzysztof Cwalina 和 Brad Abrams 发布于 2008 年 10 月 22 日。Reprinted by permission of Pearson Education, Inc. from Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition by Krzysztof Cwalina and Brad Abrams, published Oct 22, 2008 by Addison-Wesley Professional as part of the Microsoft Windows Development Series.

另请参阅See also