When related alternatives or behaviors vary by type (class), assign responsibility for the behavior—using polymorphic operations—to the types for which the behavior varies.
 Polymorphism has several related meanings. In this context, it means “giving the same name to services in different objects” [Coad95] when the services are similar or related. The different object types usually implement a common interface or are related in an implementation hierarchy with a common superclass, but this is language-dependent; for example, dynamic binding languages such as Smalltalk do not require this.
Corollary: Do not test for the type of an object and use conditional logic to perform varying alternatives based on type. ...