Jump to content

Poltergeist (computer programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 80.41.107.172 (talk) at 12:38, 9 July 2006 (Business Delegate pattern also uses poltergeist, but IS a pattern not an anti-pattern). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer programming, a poltergeist (or gypsy wagon) is a short-lived, typically stateless object used to perform initialization or to invoke methods in another, more permanent class. The original definition is by Michael Akroyd 1996 - Object World West Conference:

"As a gypsy wagon or a poltergeist appears and disappears mysteriously, so does this short lived object. As a consequence the code is more difficult to maintain and there is unnecessary resource waste. The typical cause for this antipattern is poor object design."

A poltergeist can often be identified by its name; they are often called "manager_", "controller_", "start_process", etc.

Poltergeists should not be confused with long-lived, state-bearing objects of a pattern such as Model-view-controller, or tier seperating patterns such as Business-Delegate.

To remove a poltergeist, delete the class and insert its functionality in the invoked class.

Poltergeists are examples of an anti-pattern.