I work on some customer projects where code conventions are taken very seriously, and I would like to share some thoughts with you and hopefully get any feedbacks.
The convention is:
1. Interfaces should start with the prefix "I"
2. Abstract classes should have the "Abstract" prefix
3. Function arguments should have the prefix "p"
4. Local variables should have the prefix "o"
5. Global variables should have the prefix "m"
It was a bit weird for me at first, but eventually I got used to it and found some of them very useful, let me try to tell you why:
1. I know that episode 2 mention about the "I" prefix and that it's unnecessary since the IDE tells us what is class and what is an interface. However, I found it very useful and more convenient in spring projects when using the "interface injection". For instance, I usually have an interface called "IVASTParser" and its implementation called "VASTParser". In order to avoid the "I" prefix, I've seen some people either calling the interface "VASTParser" and implementation as "VASTParserImpl", or having both called "VASTParser" but the implementation in a com.my.project.impl package. I personally think they sound a bit worse. does anybody have any better recommendation? or why should I use one or the other?
2. I partially agree that the "Abstract" prefix is unnecessary, but sometimes I think it's convenient to search for an abstract class by using Eclipse's shortcut (CTRL + SHIFT + T) and start typing "Abstract" so it filters nicely.
For 3, 4 and 5. I started to like it because it helps me when reading the code and knowing the exact scope of the variables/objects. Sometimes I have to deal with huge classes/functions and those prefixes kind of help.
Which also brings me to another last question, should global variables try to be avoided? if so, what's the alternative?
Any thoughts?