posts - 132,comments - 30,trackbacks - 2


命名

对于理解应用程序的逻辑流,命名方案是最有影响力的一种帮助。名称应该说明“什么”而不是“如何”。通过避免使用公开基础实现(它们会发生改变)的名称,可以保留简化复杂性的抽象层。例如,可以使用 GetNextStudent(),而不是 GetNextArrayElement()

命名原则是:选择正确名称时的困难可能表明需要进一步分析或定义项的目的。使名称足够长以便有一定的意义,并且足够短以避免冗长。唯一名称在编程上 仅用于将各项区分开。表现力强的名称是为了帮助人们阅读;因此,提供人们可以理解的名称是有意义的。不过,请确保选择的名称符合适用语言的规则和标准。

以下几点是推荐的命名方法。

例程

变量

Microsoft SQL Server

杂项

软件文档以两种形式存在:外部的和内部的。外部文档(如规范、帮助文件和设计文档)在源代码的外部维护。内部文档由开发人员在开发时在源代码中编写的注释组成。

不考虑外部文档的可用性,由于硬拷贝文档可能会放错地方,源代码清单应该能够独立存在。外部文档应该由规范、设计文档、更改请求、错误历史记录和使用的编码标准组成。

内部软件文档的一个难题是确保注释的维护与更新与源代码同时进行。尽管正确注释源代码在运行时没有任何用途,但这对于必须维护特别复杂或麻烦的软件片段的开发人员来说却是无价的。

以下几点是推荐的注释方法:

  • 如果用 C# 进行开发,请使用 XML 文档功能。有关更多信息,请参见:XML 文档
  • 修改代码时,总是使代码周围的注释保持最新。
  • 在每个例程的开始,提供标准的注释样本以指示例程的用途、假设和限制很有帮助。注释样本应该是解释它为什么存在和可以做什么的简短介绍。
  • 避免在代码行的末尾添加注释;行尾注释使代码更难阅读。不过在批注变量声明时,行尾注释是合适的;在这种情况下,将所有行尾注释在公共制表位处对齐。
  • 避免杂乱的注释,如一整行星号。而是应该使用空白将注释同代码分开。
  • 避免在块注释的周围加上印刷框。这样看起来可能很漂亮,但是难于维护。
  • 在部署之前,移除所有临时或无关的注释,以避免在日后的维护工作中产生混乱。
  • 如果需要用注释来解释复杂的代码节,请检查此代码以确定是否应该重写它。尽一切可能不注释难以理解的代码,而应该重写它。尽管一般不应该为了使代码更简单以便于人们使用而牺牲性能,但必须保持性能和可维护性之间的平衡。
  • 在编写注释时使用完整的句子。注释应该阐明代码,而不应该增加多义性。
  • 在编写代码时就注释,因为以后很可能没有时间这样做。另外,如果有机会复查已编写的代码,在今天看来很明显的东西六周以后或许就不明显了。
  • 避免多余的或不适当的注释,如幽默的不主要的备注。
  • 使用注释来解释代码的意图。它们不应作为代码的联机翻译。
  • 注释代码中不十分明显的任何内容。
  • 为了防止问题反复出现,对错误修复和解决方法代码总是使用注释,尤其是在团队环境中。
  • 对由循环和逻辑分支组成的代码使用注释。这些是帮助源代码读者的主要方面。
  • 在整个应用程序中,使用具有一致的标点和结构的统一样式来构造注释。
  • 用空白将注释同注释分隔符分开。在没有颜色提示的情况下查看注释时,这样做会使注释很明显且容易被找到。

格式

格式化使代码的逻辑结构很明显。花时间确保源代码以一致的逻辑方式进行格式化,这对于您和必须解密源代码的其他开发人员都有帮助。

以下几点是推荐的格式化方法。

------------------------------------------------
Capitalization Styles

Use the following three conventions for capitalizing identifiers.

Pascal case

The first letter in the identifier and the first letter of each subsequent concatenated word are capitalized. You can use Pascal case for identifiers of three or more characters. For example:

BackColor

Camel case

The first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalized. For example:

backColor

Uppercase

All letters in the identifier are capitalized. Use this convention only for identifiers that consist of two or fewer letters. For example:

System.IO
System.Web.UI

You might also have to capitalize identifiers to maintain compatibility with existing, unmanaged symbol schemes, where all uppercase characters are often used for enumerations and constant values. In general, these symbols should not be visible outside of the assembly that uses them.

The following table summarizes the capitalization rules and provides examples for the different types of identifiers.

Identifier Case Example
Class Pascal AppDomain
Enum type Pascal ErrorLevel
Enum values Pascal FatalError
Event Pascal ValueChange
Exception class Pascal WebException
Note   Always ends with the suffix Exception.
Read-only Static field Pascal RedValue
Interface Pascal IDisposable
Note   Always begins with the prefix I.
Method Pascal ToString
Namespace Pascal System.Drawing
Parameter Camel typeName
Property Pascal BackColor
Protected instance field Camel redValue
Note   Rarely used. A property is preferable to using a protected instance field.
Public instance field Pascal RedValue
Note   Rarely used. A property is preferable to using a public instance field.

------------------------------------------------
Case Sensitivity

To avoid confusion and guarantee cross-language interoperation, follow these rules regarding the use of case sensitivity:

------------------------------------------------
Abbreviations:缩写

To avoid confusion and guarantee cross-language interoperation, follow these rules regarding the use of abbreviations:

------------------------------------------------
避免单独使用下面的关键字
AddHandler AddressOf Alias And Ansi
As Assembly Auto Base Boolean
ByRef Byte ByVal Call Case
Catch CBool CByte CChar CDate
CDec CDbl Char CInt Class
CLng CObj Const CShort CSng
CStr CType Date Decimal Declare
Default Delegate Dim Do Double
Each Else ElseIf End Enum
Erase Error Event Exit ExternalSource
False Finalize Finally Float For
Friend Function Get GetType Goto
Handles If Implements Imports In
Inherits Integer Interface Is Let
Lib Like Long Loop Me
Mod Module MustInherit MustOverride MyBase
MyClass Namespace New Next Not
Nothing NotInheritable NotOverridable Object On
Option Optional Or Overloads Overridable
Overrides ParamArray Preserve Private Property
Protected Public RaiseEvent ReadOnly ReDim
Region REM RemoveHandler Resume Return
Select Set Shadows Shared Short
Single Static Step Stop String
Structure Sub SyncLock Then Throw
To True Try TypeOf Unicode
Until volatile When While With
WithEvents WriteOnly Xor eval extends
instanceof package var        
------------------------------------------------
类型名对照表
C# type name Visual Basic type name JScript type name Visual C++ type name Ilasm.exe representation Universal type name
sbyte SByte sByte char int8 SByte
byte Byte byte unsigned char unsigned int8 Byte
short Short short short int16 Int16
ushort UInt16 ushort unsigned short unsigned int16 UInt16
int Integer int int int32 Int32
uint UInt32 uint unsigned int unsigned int32 UInt32
long Long long __int64 int64 Int64
ulong UInt64 ulong unsigned __int64 unsigned int64 UInt64
float Single float float float32 Single
double Double double double float64 Double
bool Boolean boolean bool bool Boolean
char Char char wchar_t char Char
string String string String string String
object Object object Object object Object
posted @ 2007-06-05 09:58 凌度 阅读(77) 评论(0) 编辑
WWF

关于 Framework 3.0

Microsoft .NET Framework 3.0(以前称为 WinFX),是用于 Windows 的新式托管代码编程模型。它将 .NET Framework  2.0 的功能和新的结构构建应用程序技术完美结合,可提供夺目的用户视觉体验、实现跨越技术边界的无缝通信,并支持广泛的业务流程。Microsoft 计划将 .NET Framework 3.0作为 Windows Vista 的一部分来提供。同时,Microsoft 也将在 Windows XP Service Pack 2 和 Windows Server 2003 Service Pack 1 中提供 .NET Framework

下表列出了 .NET Framework 3.0 包含的若干技术。

技术 说明
Windows Presentation Foundation(WPF,以前的代号为“Avalon”) 提供用于结合 UI、文档和媒体构建下一代智能客户端应用程序的类。
Windows Communication Foundation(WCF,以前的代号为“Indigo”) 提供统一的编程模型和运行时,用以构建面向服务的应用程序。
Windows Workflow Foundation (WF) 提供编程模型、引擎和工具来构建支持工作流的应用程序,以进行业务流程建模。
Windows CardSpace(以前的代号为“InfoCard”) 通过使用个人标识信息,简化和改善在线工作安全性。
Microsoft .NET Framework 2.0 提高了构建 Windows 和基于 Web 的应用程序的效率。

所有代表新组件(WPF、WF、WCF 和 CardSpace)的类均属于系统命名空间。.NET 平台的核心类,如公共语言运行时 (CLR) 和基类库 (BCL),均保留了 .NET Framework 2.0 中的原样。


网址:

1.Windows® Workflow Foundation安装说明
http://download.microsoft.com/download/7/5/3/75356ce9-2364-4f2c-8e77-4bdc86789001/VSExtensions_for_WF_RTM_Install_Instructions.htm
2.Microsoft .NET Framework 3.0 可再发行组件包
http://download.pchome.net/php/tdownload2.php?sid=35490&url=/development/developtools/translater/dotnetfx3langpackzh-CHS.zip&svr=1&typ=1
http://www.microsoft.com/downloads/info.aspx?na=22&p=1&SrcDisplayLang=zh-cn&SrcCategoryId=&SrcFamilyId=&u=%2fdownloads%2fdetails.aspx%3fFamilyID%3d10cc340b-f857-4a14-83f5-25634c3bf043%26DisplayLang%3dzh-cn
3.Microsoft .NET Framework 3.0 语言包
http://www.microsoft.com/downloads/info.aspx?na=22&p=3&SrcDisplayLang=zh-cn&SrcCategoryId=&SrcFamilyId=&u=%2fdownloads%2fdetails.aspx%3fFamilyID%3d41c61d2a-d411-4dde-9013-bb08eb688bb6%26DisplayLang%3dzh-cn
4.Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation)
http://www.microsoft.com/downloads/info.aspx?na=22&p=2&SrcDisplayLang=zh-cn&SrcCategoryId=&SrcFamilyId=&u=%2fdownloads%2fdetails.aspx%3fFamilyID%3d5d61409e-1fa3-48cf-8023-e8f38e709ba6%26DisplayLang%3dzh-cn
5.Framework3.0 开发最权威文档
http://download.microsoft.com/download/1/b/3/1b3f749d-e215-482c-a004-5d9c26c75c92/6.0.6000.0.0.WindowsSDK_Vista_rtm.DVD.Rel.img
6.视频教程
http://msdn.microsoft.com/vstudio/express/vwd/learning/default.aspx
7.MSDN Library简体中文最新版2007-01下载
http://community.studyez.com/files/folders/39152/download.aspx
http://community.studyez.com/files/folders/develop/entry39152.aspx
posted @ 2007-06-05 09:57 凌度 阅读(40) 评论(0) 编辑