词条 | Poltergeist (computer programming) |
释义 |
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. It is considered an anti-pattern. 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_", "supervisor", "start_process", etc. Sometimes, poltergeist classes are created because the programmer anticipated the need for a more complex architecture. For example, a poltergeist arises if the same method acts as both the client and invoker in a Command pattern, and the programmer anticipates separating the two phases. However, this more complex architecture may actually never materialize. Poltergeists should not be confused with long-lived, state-bearing objects of a pattern such as Model-view-controller, or tier-separating patterns such as Business-Delegate. To remove a poltergeist, delete the class and insert its functionality in the invoked class, possibly by inheritance or as a mixin. See also
References*{{cite book |last=Brown |first=William J. |title=AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis |year=1998 |publisher=John Wiley & Sons |location=New York, USA |isbn=0-471-19713-0 |chapter=Chapter 5: Software Development AntiPatterns}}External links
1 : Anti-patterns |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。