Use of the suffix "base" when naming types
I sometimes see types named with a suffix of "base", presumably meaning it forms the parent of one or more sub-types. Is implying the use of inheritance in the type name like this a 开发者_StackOverflow社区code smell?
Very often the "Base" suffix is used for abstract classes.
It is also a common practice to give an implementation for each interface you provide in your API. When these implementations are abstract classes, used to implement logic common to all implementations, the suffix "Base" is appended to the name of the class which by convention lets consumer know they should inherit from that class for their concrete implementation.
Sometimes the common features of two child classes does not have a natural language equivalent, or the most obvious name would result in a name collision. In such cases I sometimes use a suffix in this manner. I would not consider it a code smell unless it was part of the exported API intended for use by other developers using a library.
精彩评论