A HNC, or hungarian naming convention (hungarian because reportedly the first inventor was hungarian programmer Charles Simonyi at Microsoft), is the methodology of prefixing variables with one or more letters to indicate their type. The Sun Coding Conventions do not use HNC.
The HNC variant presented in this article applies only to variables,
not to methods; methods should make their type clear thru their names,
e.g. isXXX
for booleans, getXXXValue
for
numericals, etc.
It is designed for ease of application and minimal visual clutter,
which results in the usage of as few letters as possible.
Letter | Description | Example |
---|---|---|
a<x> | Array of <x> | Object[] aoVals |
b | byte, short | byte bVal |
c | char | char cLetter |
d | double | double dVal |
e | Enumeration, Iterator | Enumeration eVals |
f | float | float fVal |
g | GUI component | JComboBox gChoice |
h | Hashtable, HashMap | HashMap hData |
i | int | int iVal |
j | - | - |
k | - | - |
l | long | long lDate |
m | - | - |
n | Numerical (Date, Dimension, BigInteger, ...) | BigDecimal nVal |
o | Object (whenever nothing else applicates) | MidiChannel oChannel |
p | - | - |
q | - | - |
r | - | - |
s | String, StringBuffer | String sLine |
t | boolean (truth value) | boolean tRunning |
u | - | - |
v | Vector, ArrayList | ArrayList vData |
w | - | - |
x | - | - |
y | - | - |
z | - | - |