经过三个月的不懈努力和反复检查,我们项目组终于完成了一份80页的VC++, VC#, VB.NET 编码规范。所有一站式示例代码库里的示例代码将以此为标准进行编写。我也希望这份编码规范能或多或少帮助到博客园里的朋友们编写更加优质统一的代码。

 

下载地址:http://1code.codeplex.com/releases/50431/download/141770

 

 

VC++, VC#, VB.NET 编码规范 (微软一站式示例代码库)


该文档主要分为三块:

General Coding Standards (即VC++, VC#, VB.NET 共通的一些编码规范)

C++ Coding Standards (C++ 特有的编码规范)

.NET Coding Standards (VC#, VB.NET 特有的编码规范)

 

该文档编写过程中得到了不少微软专家级开发工程师的审阅。文档中包含不少产品组使用的编码 best practices。比如:

Do use sizeof(var) instead of sizeof(TYPE). To be explicit about the size value being used whenever possible write sizeof(var) instead of sizeof(TYPE_OF_VAR). Do not code the known size or type of the variable. Do reference the variable name instead of the variable type in sizeof:

    Good:

    MY_STRUCT s;

    ZeroMemory(&s, sizeof(s));

    Bad:

    MY_STRUCT s;

    ZeroMemory(&s, sizeof(MY_STRUCT));

Do not use sizeof for arrays to get the element number. Use ARRAYSIZE.

 

这份编码规范仍在不断改进。如果你注意到一些good coding practice没有被记录在这份文档里,请告知我们: onecode@microsoft.com. 定予以重谢! :-)

相关文章:

  • 2021-05-04
  • 2021-04-01
  • 2021-12-24
  • 2021-06-13
猜你喜欢
  • 2021-09-18
  • 2022-12-23
  • 2022-01-21
  • 2021-08-19
  • 2021-06-05
  • 2021-10-24
相关资源
相似解决方案