Hungarian Indexes
March 17th, 2006[ Software Development ]
So I still sit firmly on the fence when it comes to hungarian notation in code. I’ve experienced it misused so badly over and over again that I’m hesitant to commit myself again. You can look into it’s history here (link courtesy of Joel). I will, however, say that I love it when used on database table indexes.
I find that prefixing a table’s index with “ix” makes life so much simpler. The table named “User” has an index named “ixUser”, “Role” has an index “ixRole”. It’s quite clear when you’re looking at the columns for User that the column “ixRole” establishes a relationship to a table called “Role”.
Contrast that with the myriad of databases I’ve seen with tables filled with index columns named “index”. How does that do anything for anyone? Or inconsistent naming where some indexes are “UserIndex” while others are “RoleId”.
Obviously the important part is being consistent but the ix prefix is where I’m at today.