The .NET coding guidelines say that having an empty base class or interface (also called “tag” interface) is indeed bad style. The preferred style is to use an attribute instead to annotate classes of the same kind. There is also an FxCop rule to enforce this convention.
However, I sometimes (in rare cases) use this idiom when a common base class is useful to denote a common hierarchy even if no common functionality exists. Attributes cannot be used for this.
For example, in an interpreter for a programming language several methods return a special base class Value
, i.e. something which has a value inside that programming language. Basically, this value can be everything from a number to a string (which, are special classes, not System.Int32
or System.String
) to a composite object. I could also return System.Object
but this would make the typing of my public interface weaker.
Good, self-documenting code profits from the restricted interface.