Poltergeist

The smell occurs when classes are created that have limited responsibility within the operation of a system. It can appear in a number of different forms but their idea is the same, poltergeist classes do not have an important role in an OO design. Furthermore, poltergeist classes have a short life cycle and represent a waste of resources when they are used.

Riel classifies 5 different ways in which this anti-pattern may appear in an OO design. 1) Irrelevant classes: An irrelevant class is a class that does not have any meaningful behaviour in the design. These types of classes are characterised for being composed only of get, set and/or print methods, 2) Agent classes: Agent classes are classes that are formed by methods that are only responsible for passing messages from one class to another, 3) Out of scope classes: A class is classified as out of the scope of the system if it sends messages to other classes but it never receives any message back, 4) Operation classes: Operation classes are characterised for being composed of only one meaningful behaviour and for having a short life cycle, and 5) Object classes: Object classes are subclasses that should be instances of their parent class instead of being classes themselves.

Related smells: Imperative Abstraction Unnecessary Abstraction

Reference

A. J. Riel, “Object-Oriented Design Heuristics”. Addison-Wesley, 1996.


Design Smells

Home

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