【数据库编程标准规范系列】之第五章:命名约定
定义完善的变量: 数据类型和作用域 表义性强的变量名,来说明这些变量 必须赋予焦点 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

AI Hentai Generator
Generate AI Hentai for free.

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

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

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

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

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Python is an ideal programming introduction language for beginners through its ease of learning and powerful features. Its basics include: Variables: used to store data (numbers, strings, lists, etc.). Data type: Defines the type of data in the variable (integer, floating point, etc.). Operators: used for mathematical operations and comparisons. Control flow: Control the flow of code execution (conditional statements, loops).
