uncategorized

Class naming

In the process of writing one of the chapters in the brownfield book, I started thinking about class naming. Some time ago I remember hearing someone saying that they didn’t much like the use of class names that ended in ‘er’ even if they conveyed good intent. For example:

SpellChecker

or

NameParser

My understanding is that the dislike stemmed from the thought that the use of ‘er’ made the name of the class to much like a verb, and that verbs were the domain of a method name. I bought into it when I first heard this. Now I’m not so sure. In some cases I fully agree. Other times I find it a little restrictive. At times I’d change the name of SpellChecker to SpellCheckingService, and NameParser to NameParsingService. No more ‘er’ ending, but it does start to encroach on another naming guideline that I have: don’t use pattern names in class names.

In the end we want the class names to be intention revealing. More-so the combination of class and method name should be intention revealing. What do you people do in these situations?