Hungarian Notation

Charles Simonyi is credited with first discussing Hungarian Notation. It is a variable naming convention that includes C++ information about the variable in its name (such as data type, whether it is a reference variable or a constant variable, etc). Every company and programmer seems to have their own flavor of Hungarian Notation. The following is just what we thought seemed easy for beginning students to understand.

Prefix Type Example
b boolean bool bStillGoing;
c character char cLetterGrade;
str C++ String string strFirstName;
si short integer short siChairs;
i integer int iCars;
li long integer long liStars;
f floating point float fPercent;
d double-precision floating point double dMiles;
ld long double-precision floating point long double ldLightYears;
sz Old-Style Null Terminated String char szName[NAME_LEN];
if Input File Stream ifstream ifNameFile;
is Input Stream void fct(istream &risIn);
of Output File Stream ofstream ofNameFile;
os Output Stream void fct(ostream &rosIn);
S declaring a struct struct SPoint
{
C declaring a class class CPerson
{
struct name or abbrev declaring an instance of a struct SPoint pointLeft; 
SPoint ptLeft; // or abbrev. (be consistent)
class name or abbrev declaring an instance of a class CPerson personFound;
CPerson perFound; // or abbrev. (be consistent)

The following table contains letters that go before the above prefixes.

Pre-prefix Type Example
u unsigned unsigned short usiStudents;
k constant formal parameter void fct(const long kliGalaxies)
r reference formal parameter void fct(long &rliGalaxies)
s static static char scChoice;
rg array (stands for range) float rgfTemp[MAX_TEMP];
m_ member variable of a struct or class char m_cLetterGrade;
p pointer to a single thing char *pcGrade;
prg dynamically allocated array char *prgcGrades;

时间: 2024-08-22 20:10:12

Hungarian Notation的相关文章

关于命名规则的一些想法

变量命名和代码约定在项目中往往是一个比较难处理的议题,程序员倾向于使用其个人的命名约定,而不喜欢别人规定他们如何编写代码. 然而,当代码需要为团队内的其他成员阅读时(特别是代码检查的时候),拥有通用的命名约定是很有价值的,拥有通用的命名约定也便于自己日后再阅读自己的代码.这中体会在几次项目以后,体会更加深刻.所以才有想要统一团队命名规则的想法. 一直以来,最流行的变量命名约定是所谓的匈牙利表示法(Hungarian Notation).最初由Microsoft的Charles Simonyi提出

Java编程准则

编程|准则 Java编程准则内容摘录自:<Java 编程思想>第2版<附录C J a v a 编程准则>/(美) 埃克尔(Eckel,B)著:候捷译的,机械工业出版社,2002.9 版权归原作者和原出版社. 这份附录所提供的建议,可以帮助你进行低阶的程序设计,并帮助你写码. 当然,这些都只是一种方针而不是硬性规则.你应该视它们为一种灵感来源.记住,某些情况下你需要加以变通或甚至打破规则.设计 1. 优雅需要付出代价.从短期利益来看,对某个问题提出优雅的解决方法,似乎可能花你更多的时

IDesign C#编程规范(一)

编程|规范 IDesign发布了C#编程规范,小鸡射手从Only4Gurus下载浏览后决心抽时间翻译一下,以更好地学习. 目录内容如下: 1 命名规则和风格 Naming Conventions and Style 2 编码惯例 Coding Practices 3 项目设置和结构 Project Settings and Structure 4 Framework特别指导 Framework Specific Guidelines 4.1 数据访问 Data Access 4.2 ASP.NE

C# Programming guidlines

guid C# Programming guidlinessource: Thinking in C# Larry O'Brien and Bruce Eckel Prentice HallUpper Saddle River, New Jersey 07458www.phptr.com begin: This appendix contains suggestions to help guide you in performing low-level program design, and i

C# Programming Guidelines

guid source: this article is from a book named<thinking in c#>,if you are interested in the book,you'd better to have a real book made by paper :) Thinking in C# Larry O'Brien and Bruce Eckel Prentice HallUpper Saddle River, New Jersey 07458www.phpt

Google C++编程风格指南(八):规则之例外

编程风格指南的使用要点在于提供一个公共的编码规范,所有人可以把精力集中在实现内容而不是表现形式上.我们给出了全局的风格规范,但局部的风格也很重要,如果你在一个文件中新加的代码和原有代码风格相去甚远的话,这就破坏了文件本身的整体美观也影响阅读 规则之例外 前面说明的编码习惯基本是强制性的,但所有优秀的规则都允许例外. 1. 现有不统一代码(Existing Non-conformant Code) 对于现有不符合既定编程风格的代码可以网开一面. 当你修改使用其他风格的代码时,为了与代码原有风格保持

《C++程序设计教程(第3版)》——第2章,第1节保留字和标识符

第2章 数据类型.运算符和表达式学习编写程序之前,首先要了解程序的基本组成要素.从语法形式上说,C++程序由一些符号.单词.数据和语句组成:从逻辑上说,程序=数据结构+算法.所以必须首先了解构成程序的符号.单词.数据和语句.本章主要介绍构成程序的基本语法要素. 2.1 保留字和标识符2.1.1 保留字保留字(Reserved Word)也称为关键字(Keyword),它们是C++预先定义的字符序列,具有特殊的含义及用法,用于构成语言自身的语法要素,编程者不能将它们用作自己的变量名或函数名等,如例

PowerDesigner概念模型的Notation设置

原文:PowerDesigner概念模型的Notation设置 在进行数据库设计模型时,分为概念模型设计和物理模型设计两种,概念模型主要是反映真是 世界中的业务关系,也就是我们常用的实体关系图.物理模型是在概念模型设计好后通过概念模型直接转换生成的,然后再对系统生成的物理模型进行修改.概念模 型的建模主要靠的是建模人员的业务理解能力,而物理模型的建模主要靠的是建模人员对某个数据库产品的熟悉和相关的技术水平. 在 PowerDesigner中新建一个概念数据模型,可以选择模型的Notation,在

Ajax中数据传递的另一种模式 javascript Object Notation思想(JSON)_AJAX相关

Ajax是"异步javascript和XML"的缩写已经众所周知,然而虽然XML是看上去的重要组成部分,它却不是必须的.一位资深的软件工程师Douglas Crock ford 开发了一个内建于 javascript 的数据格式,称为javascript 对象表示(JSON,javascript Object Notation),意思是直接使用Ajax对象来传递信息,可以读作"Jason". 1. 什么是 JSON JSON概念很简单,JSON 是一种轻量级的数据格