【数据库编程标准规范系列】之第五章:命名约定
定义完善的变量: 数据类型和作用域 表义性强的变量名,来说明这些变量 必须赋予焦点 5.1 编程原则 有焦点的变量:服务于一个定义明确的目的 无焦点的变量:用于多个目的的变量 焦点的变量 为变量赋予表义性强的名字 增强可读性 淘汰故意缩短的变量名 避免 T
定义完善的变量:
数据类型和作用域
表义性强的变量名,来说明这些变量
必须赋予焦点
5.1编程原则
有焦点的变量:服务于一个定义明确的目的
无焦点的变量:用于多个目的的变量
焦点的变量
为变量赋予表义性强的名字
增强可读性
淘汰故意缩短的变量名
避免Temp,临时变量,暂时性变量
变量名中混合使用大小写字母
Dim strFirst_Name As String
只对常用变量名和长变量名进行缩写,最长不超过32个字符
缩写规则:
一致性,前后统一
选用表义性强的缩写
对变量名中公用部分缩写,专用部分不应缩写
使用统一的量词
变量名结尾处,使用标准化量词:
Dim strCustomerFirst As String
Dim strCustomerLast As String
Dim strCustomerPrevious As String
显式说明变量
建议:显示说明变量
如:Dim、Private、Public或Static
显示按钮:Explicit Option
最佳数据类型,减少内存需求,加快执行速度,降低出错可能,不同数据类型影响计算结果
数字计算:
防止溢出错误
遵循规则:
存储任何类型的文本,String数据类型,包含任何有效的键盘字符,包括数字和非字母字符
存放True和False这两个值,Boolean数据类型
存放不包含小数位、大于或等于-32768、小于或等于32767的数字,用Integer
存放不带小数位的数字,但是数字值大于或小于Integer数据类型允许的值,Long
包含小数位的数字,Single
大于Single数据类型能够存放的数字,Double
存放美元金额,请使用Currency数据类型
存放日期或时间值,请使用Date
只有在绝对必要时,Variant
变量的作用域,对于过程和模块来说它的可视性,应尽量缩小(降低错误率,防止占用资源)
作用域等级,即:过程作用域、模块作用域、全局作用域

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The Xiaomi Mi 15 series is expected to be officially released in October, and its full series codenames have been exposed in the foreign media MiCode code base. Among them, the flagship Xiaomi Mi 15 Ultra is codenamed "Xuanyuan" (meaning "Xuanyuan"). This name comes from the Yellow Emperor in Chinese mythology, which symbolizes nobility. Xiaomi 15 is codenamed "Dada", while Xiaomi 15Pro is named "Haotian" (meaning "Haotian"). The internal code name of Xiaomi Mi 15S Pro is "dijun", which alludes to Emperor Jun, the creator god of "The Classic of Mountains and Seas". Xiaomi 15Ultra series covers

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Since the Huawei Mate60 series went on sale last year, I personally have been using the Mate60Pro as my main phone. In nearly a year, Huawei Mate60Pro has undergone multiple OTA upgrades, and the overall experience has been significantly improved, giving people a feeling of being constantly new. For example, recently, the Huawei Mate60 series has once again received a major upgrade in imaging capabilities. The first is the new AI elimination function, which can intelligently eliminate passers-by and debris and automatically fill in the blank areas; secondly, the color accuracy and telephoto clarity of the main camera have been significantly upgraded. Considering that it is the back-to-school season, Huawei Mate60 series has also launched an autumn promotion: you can enjoy a discount of up to 800 yuan when purchasing the phone, and the starting price is as low as 4,999 yuan. Commonly used and often new products with great value

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

C is an ideal language for beginners to learn programming, and its advantages include efficiency, versatility, and portability. Learning C language requires: Installing a C compiler (such as MinGW or Cygwin) Understanding variables, data types, conditional statements and loop statements Writing the first program containing the main function and printf() function Practicing through practical cases (such as calculating averages) C language knowledge

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

Pythonempowersbeginnersinproblem-solving.Itsuser-friendlysyntax,extensivelibrary,andfeaturessuchasvariables,conditionalstatements,andloopsenableefficientcodedevelopment.Frommanagingdatatocontrollingprogramflowandperformingrepetitivetasks,Pythonprovid

To avoid PHP database connection errors, follow best practices: check for connection errors and match variable names with credentials. Use secure storage or environment variables to avoid hardcoding credentials. Close the connection after use to prevent SQL injection and use prepared statements or bound parameters.
