Hungarian Naming Convention for Java

Intro

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.

The HNC for Java

Letter Description Example
a<x>Array of <x>Object[] aoVals
bbyte, shortbyte bVal
ccharchar cLetter
ddoubledouble dVal
eEnumeration, IteratorEnumeration eVals
ffloatfloat fVal
gGUI componentJComboBox gChoice
hHashtable, HashMapHashMap hData
iintint iVal
j--
k--
llonglong lDate
m--
nNumerical (Date, Dimension, BigInteger, ...)BigDecimal nVal
oObject (whenever nothing else applicates)MidiChannel oChannel
p--
q--
r--
sString, StringBufferString sLine
tboolean (truth value)boolean tRunning
u--
vVector, ArrayListArrayList vData
w--
x--
y--
z--

EOF (Aug:2003)