It is recommended that type names and virable names should avoid using abbreviations. It is also recommanded the source line width should be 80 or at most 120 characters even if modern wide screen monitors are used.
Here is a line from our real prject:
final PimAuthoringApplicationMappingReader pimAuthoringApplicationMappingReader =
new PimAuthoringApplicationMappingReader(pimAuthoringApplicationMappingFile);
A simple new operation occupied at least 2 lines, even though we have used an abbreviation here already (Pim = ProIntralink Merge).
Although it is easy to understand each words in this way, it makes a simple method much longer, and therefore difficult to fit one method in screen.
Question: what is the better way to deal with this case? Is “reasonable” abbreviation recommended – for example:
final PimAuthAppMapReader pimAuthAppMapReader=new PimAuthAppMapReader(pimAuthAppMapFile);
?
That’s a familiar problem, the Java project I’m working on has some classes that make me scratch my head for the same reason. I shorten the local variable names before shortening the class names, but I have no problem shortening class names if the result is reasonable.
Breaking the convention of making the local variable the same name as its type frees up quite a bit of space in these cases. If more space is needed, I might shorten the type names as well.
In your example, I’m fine with shortening Application to App, but not so sure about shortening Mapping to Map because “map” has a different primary meaning (first association) in Java.