Naming Classes - How to avoid calling everything a "<WhatEver>Manager"?
I asked a similar question, but where possible I try to copy the names already in the .NET framework, and I look for ideas in the Java and Android frameworks.
It seems Helper
, Manager
, and Util
are the unavoidable nouns you attach for coordinating classes that contain no state and are generally procedural and static. An alternative is Coordinator
.
You could get particularly purple prosey with the names and go for things like Minder
, Overseer
, Supervisor
, Administrator
, and Master
, but as I said I prefer keeping it like the framework names you're used to.
Some other common suffixes (if that is the correct term) you also find in the .NET framework are:
Builder
Writer
Reader
Handler
Container
You can take a look at source-code-wordle.de, I have analyzed there the most frequently used suffixes of class names of the .NET framework and some other libraries.
The top 20 are:
- attribute
- type
- helper
- collection
- converter
- handler
- info
- provider
- exception
- service
- element
- manager
- node
- option
- factory
- context
- item
- designer
- base
- editor
I'm all for good names, and I often write about the importance of taking great care when choosing names for things. For this very same reason, I am wary of metaphors when naming things. In the original question, "factory" and "synchronizer" look like good names for what they seem to mean. However, "shepherd" and "nanny" are not, because they are based on metaphors. A class in your code can't be literally a nanny; you call it a nanny because it looks after some other things very much like a real-life nanny looks after babies or kids. That's OK in informal speech, but not OK (in my opinion) for naming classes in code that will have to be maintained by who knows whom who knows when.
Why? Because metaphors are culture dependent and often individual dependent as well. To you, naming a class "nanny" can be very clear, but maybe it's not that clear to somebody else. We shouldn't rely on that, unless you're writing code that is only for personal use.
In any case, convention can make or break a metaphor. The use of "factory" itself is based on a metaphor, but one that has been around for quite a while and is currently fairly well known in the programming world, so I would say it's safe to use. However, "nanny" and "shepherd" are unacceptable.