I have serious OCD about naming. Sometimes I just sit and think (or talk out loud..) about what a good/better name for whatever is.
And I really mean whatever- package names, class names, method names, variable names, project names, component names, build tasks.. Along with naming OCD, I also have convention OCD such as: singular or plural names (for database tables, packages), camelCase vs snake_case, space vs tab, 2 vs 4 vs 8 space indentation.
However, I’ve got a few preferences, only they sometimes are in conflict and I haven’t decided on how much weight each has (need to figure it out still). They are:
- when trying to keep things ordered, put them in alphabetic order (ignores, properties, imports, fields, setters/getters)
- when trying to find a name, given two real synonyms, use the shorter of the two (but it has to convey the same meaning)
- avoid abbreviations and acronyms (this is in conflict with the previous preference..)
- name it using English
For that last reason I’ll give an example. I have a project that uses assignments. Without going into detail, I sometimes deal with lists of assignments, other times maps of assignments. I, therefore, have started using the convention of writing variables such as assignmentsMap instead of assignmentMap, because the variable represents a map, a map of what? of assignments. Not of ‘assignment’. I think it’s a good convention to use.