No Peter Pan objects

From CSSEMediaWiki
Jump to: navigation, search

Do not create something that lives forever and lose track of it.

When creating objects that may linger indefinitely especially those who have their own resident thread always keep a reference. For purposes such as pausing a program's execution it is vital to have a handle to each object that may have a separate execution path.

Solutions

  • Chain of responsibility - Make each object responsible for passing thread control messages to any children it instantiated.
  • Singleton - Create a thread registry, this will contain methods to construct a new thread for a client and maintain a list of threads that have been constructed. This way the registry can directly manage the execution state of threads.
Personal tools