HN学习整理
来源:互联网 发布:网络安全法 实名备案 编辑:程序博客网 时间:2024/05/01 12:15
基本原则
变量名 = 属性 + 类型 + 对象描述
名称要求有明确含义,可以去全称或简称,保证名字的连贯性
通用的命名习惯
属性部分
g_ 全局变量
c_ 常量
m_ 类成员变量
s_ 静态变量
类型部分
a 数组
p 指针
fn 函数
v 无效
h 句柄
l 长整型
b 布尔
f 浮点/文件
dw 双字
sz 字符串
n 短整型
d 双精度浮点
c/cnt 计数
c/ch 字符
i 整型
by 字节
w 字
r 实型
u 无符号
举例
hwnd h是类型描述,表示句柄,wnd是变量对象描述,表示窗口,所以hwnd表示串口句柄
pfnEatApple pfn是类型描述,表示指向函数的指针,EatApple是变量对象描述,所以pfnEatApple 表示指向EatApple函数的函数指针变量
g_cch g_是属性描述,表示全局变量,c和ch分别是计数类型和字符类型,一起表示变量类型,所以g_cch表示一个对字符进行计数的全局变量
常见变量命名规范
lpsz LPSTR 32位字符串指针 lpszName
lpsz LPCSTR 32位常量字符串指针 lpszName
lpsz LPCTSTR 如果_UNICODE定义,则为32位常量字符串指针 lpszName
h handle Windows对象句柄 hWnd
• g_nWheels : member of a global namespace, integer
• m_nWheels : member of a structure/class, integer
• m_wheels, _wheels : member of a structure/class
• s_wheels : static member of a class
• c_wheels : static member of a function
• bBusy : boolean
• chInitial : char
• cApples : count of items
• dwLightYears : double word (Systems)
• fBusy : float (or flag)
• nSize : integer (Systems) or count (Apps)
• iSize : integer (Systems) or index (Apps)
• fpPrice: floating-point
• dbPi : double (Systems)
• pFoo : pointer
• rgStudents : array, or range
• szLastName : zero-terminated string
• u16Identifier : unsigned 16-bit integer (Systems)
• u32Identifier : unsigned 32-bit integer (Systems)
• stTime : clock time structure
• fnFunction : function name
根据前缀的使用习惯不同,分为systems notation和Apps Notation
In Systems Hungarian notation, the prefix encodes the actual data type of the variable.
Apps Hungarian notation strives to encode the logical data type rather than the physical data type; in this way, it gives a hint as to what the variable’s purpose is, or what it represents.
习惯命名:
Systems notation
• lAccountNum : variable is a long integer (“l”);
• arru8NumberList : variable is an array of unsigned 8-bit integers (“arru8”);
• szName : variable is a zero-terminated string (“sz”); this was one of Simonyi’s original suggested prefixes.
• bReadLine(bPort,&arru8NumberList) : function with a byte-value return code.
Apps notation
• rwPosition : variable represents a row (“rw”);
• usName : variable represents an unsafe string (“us”), which needs to be “sanitized” before it is used
• strName : Variable represents a string (“str”) containing the name, but does not specify how that string is implemented.
参考资料
百度百科 http://baike.baidu.com/view/419474.htm
Wikipedia https://en.wikipedia.org/wiki/Hungarian_notation
- HN学习整理
- hn 10432 棋盘覆盖
- HN集训比赛总结
- HN集训2015酱油记 - day1
- HN集训201(5+6)酱油记
- HN有一个奇葩的性能问题
- Android学习整理-Intent整理
- html <hn>应该在<a>的里面还是外面?
- HN OJ 13375 Flowery Trails (spfa的路径遍历)
- HN OJ 13375 Flowery Trails (spfa的路径遍历)
- MitraStar DSL-2401HN-T1C-GV硬件与启动信息
- [BZOJ1555][HN集训2008]KD之死(贪心+堆)
- 转载:Ask HN: Relationship between OO and functional programming?
- html p,br,hn,img,a标签的使用
- OWB学习经验整理
- MO学习整理
- 学习整理清单
- J2ME学习笔记整理
- form中appendChild失效的问题
- httpd下载地址
- Lock与synchronized 的区别
- jsp页面获取服务器Ip地址
- OC self关键字
- HN学习整理
- http://blog.csdn.net/jiyiqinlovexx/article/details/51173080
- [翻译]Spark编程指南(Python版)
- C++ 在图片上打印文字并保存图片
- 关于oneinstack mysql远程连接
- word工具栏不见了怎么办 word工具栏怎么还原
- Linux下查看MySQL的安装路径
- DNS请求分析
- JDBC在getConnection之前为什么要调用Class.forName