Improper use of synonyms in object naming
“The misuse of language induces evil in the soul.”
A difficult part of programming is clear naming for classes variables and functions.
Before I begin I’ll take it as an axiom that naming inconsistency is always undesired.
For example that Java object you’re working with should you call: setText(), setTitle() or setLabel(); getSize() or getLength()?
http://mindprod.com/jgloss/inconsistencies.html
Another naming phenomenon that I think needs to be addressed is the used of synonyms in object names.
For example all classes in Java are subclasses of “Object”.
When someone has a very general class that is extended by many other classes, and they lack the creativity or sophistication to think of a proper descriptive name, they often use a synonym of “Object” such as “Entity”, “Element”. This is no different than naming a class “Object”, except that it degrades naming consistency.
For more distinct names I think this is obvious to most people. If you have an application the deals with “cars” you wouldn’t want the source code to use “car” in some places and “automobile” or “vehicle” in others. You pick one of the synonyms and stick with it.
This same precept, not using more than one of a group of synonyms, applies to more general terms as well, if not more. This mix of synonyms and inconsistency creates the perfect storm of meaninglessness.
What to use instead of synonyms -> adjectives.
Instead of having a Java project in which there exists the following classes:
Object
| - Element
| - Entity
| - Item
| - …
All of which are synonms, and you must learn the domain specific and arbitrary distintion between them.
Be consistent with the use of Object (choosen for us by the authors of Java) and use adjectives to quantify the class names.
Object
| - PayrollObject
| - DrawableObject
| - DatabaseObject
(Notice that the Java authors have also fallen into this pitfall with the deprecate addElement()… methods names. addElement() should really be addObject() to be consistent, but this becomes redundant, shortening it to add() )
Some names are even redundant, many class names would be fine without the “Element”/”Enity” suffix.
I’ll take this a little further, because I think there is something even more unseemly behind this behavour besides the difficulty of using descriptive and coherent language. I think part of the force behind the use of “Entity” and “Element” and “EnityElement” is the distastful human inclination toward euphamism. (Sorry, the vile inclination toward euphamism).
“The more syllables a euphemism has, the further divorced from reality it is”
All you have to do now is count: Object … 2, Entity … 3, Element … 3, ...