Type Queries

Type queries in the system (e.g., using instanceof) can be regarded as smells: the inheritance relation expresses itself not only in the classes of the inheritance hierarchy, but in the clients too. In regard to the design principles, type queries violate the Once and only once principle (or, DRY - Don't Repeat Yourself principle).

Related smells: Unexploited Encapsulation Switch Statement

Reference

M. Lippert, S. Roock, “Refactoring in Large Software Projects: Performing Complex Restructurings Successfully”. John Wiley and Sons, 2006.


Design Smells

Home

All rights reserved (c) Tushar Sharma 2017-23.