Reverse Hungarian
You’ve heard of Hungarian Notation? Now try the ‘logical’ progression from this, Reverse Hungarian! Instead of starting the name with the type, end with type.
For simplicity, here’s a lightweight list of types. In the true spirit of this naming scheme, feel free to add and adapt these however you see fit.
- i - interface
- o - object class
- n - number
- t - text
- c - currency
- d - date
- m - method/function
e.g.
- Personi
- Managero
- Employeo
- Customero
- Namet
- Agen
- pricec
- dated
Some lovely method names:
- savem
- deletem
- loadem
- initialisem
- getSelectedActionTypem
- randomum
Replace vowels if needed for readability.
- Vehicli
- Bicyclo
- Caro
- Trucko
Add a ‘e’ or ‘u’ to further increase pronunciation. Avoid real words.
- counten
- speeden
- xun, yun
- cityet
- descriptionet
- emailen
- timestamped
As you can see this is a great improvement on undecorated naming conventions, and far superior to regular Hungarian Notation in all the ways that really matter.
Benefits of this new and exciting naming system include:
- having names that are easier to sort and locate by order and yet have type information embedded
- not confusing them with real words
- being able to find type with a simple regex
- they are pronouncable, so you can have real conversation about them
- they aren’t actual words so search and replace doesn’t affect real text such as labels if you are careful
- they add colour and flair to your code, making it faster to learn and remember what things are