关于平台软件开发的若干代码编制规范(试行版)
关于平台软件开发的若干
代码编制规范
(试行版 v1.0)
2009-02
1
关于平台软件开发的若干代码编制规范(试行版)
关于平台软件开发的若干代码编制规范(试行版)
一、 关于程序块结构
总体程序结构包括以下几类:
1、 通用类函数
涉及到的通用类型函数或访问技术(如文件/数据库访问,同类应用的标准函数集
封装等),须作集中申明,放在类模块中,每个类在单独的文件中维护。由软件
平台技术牵头人负责维护。
示例如下:
2、 通用功能函数
涉及到的通用功能函数,集中申明,放在模块中,并在一个文件中维护。由软件
平台技术牵头人负责维护。
示例如下:
2
关于平台软件开发的若干代码编制规范(试行版)
Example
:
Attribute VB_Name = "Module1"
'====================================================''
Error Handling and write error log
' All rights reserved.
'version 1.0
'====================================================
Option Explicit
Private strErrLogFilePath As String
Private strMessage As String
Private strCaption As String
Public Sub writeErrorLog(strModule As String, _
strProcedure As String, _
IngErrorNumber As Long, _
strErrorDescription As String, _
strOperator As String)
On Error GoTo PROC_ERR
'
错误日志文件路径
strErrLogFilePath = App.Path & "\ErrLog" & Format(Now, "YYYYMMDD") & ".txt"
'
打开错误日志文件(没有就产生)
Dim fs, fErrLog
Set fs = CreateObject("Scripting.FileSystemObject")
Set fErrLog = fs.opentextfile(strErrLogFilePath, 8, 1) '
写日志
fErrLog.writeline "**** Error Encountered " & VBA.Now & "*****"
fErrLog.writeline "Error Number:" & IngErrorNumber
fErrLog.writeline "Error Description:" & strErrorDescription
fErrLog.writeline "Procedure:" & strProcedure
fErrLog.writeline "Module:" & strModule
fErrLog.writeline "Operator:" & strOperator
3