Probablemente te has encontrado código como (Systems Hungarian notation):
AccountNum
: 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.arrlstCbomPagedDetails
: ArrayList in java.arrStudents
: variable is an array in Java of object used for students;rwPosition
: variable is a int with a position in a Table;
Las reglas más normales son:
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) |
Y por delante:
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; |
Pros:
- Reglas mnemotécnicas
- Más farragoso
- Renombra las variables
Como en todo, hay gente a favor, y gente en contra. Decide por ti mismo. Si quieres más información pasate por aquí
Si buscas otros estilos o formas de hacer las cosas, cada maestrillo tiene su librillo, pero recomiendo usar alguno de los siguientes:
Y algunos consejos para la programación segura:
Fuente, y esta
No hay comentarios:
Publicar un comentario