Pampoo make intensive use of GOF (Gang of Four) patterns. Pampoo makes available to overlying projects three of those patterns to help you integrate these practices without reinventing the wheel. More informations here

Command chain

Building on the loose-coupling theme, the chain-of-command pattern routes a message, command, request, or whatever you like through a set of handlers. Each handler decides for itself whether it can handle the request. If it can, the request is handled, and the process stops. You can add or remove handlers from the system without influencing other handlers
class Pampoo_GOF_CommandChain
{
  private $_commands = array();

  public function addCommand( Pampoo_GOF_ICommand $cmd )
  {
    $this->_commands []= $cmd;
  }

  public function runCommand( $name, $args )
  {
    foreach( $this->_commands as $cmd )
    {
      if ( $cmd->onCommand( $name, $args ) )
        return;
    }
  }
}

interface Pampoo_GOF_ICommand
{
  function onCommand( $name, $args );
}

This is a sample of use of that pattern taken from the static method Run inside the main Pampoo class (Pampoo.php):
$ap = new Pampoo_Framework_Application(self::$sitemap, $ErrorObserver);
$cc = new Pampoo_GOF_CommandChain();

$cc->addCommand( new Pampoo_Framework_Command_UrlParseCommand($Observers) );
$cc->addCommand( new Pampoo_Framework_Command_ActionCommand($Observers) );
$cc->addCommand( new Pampoo_Framework_Command_BLLCommand($Observers) );
$cc->addCommand( new Pampoo_Framework_Command_DataCommand($Observers) );

$cc->runCommand( 'urlparse', $ap );
$cc->runCommand( 'action', $ap );
$cc->runCommand( 'bll', $ap );
$cc->runCommand( 'data', $ap );

Observer

The observer pattern gives you another way to avoid tight coupling between components. This pattern is simple: One object makes itself observable by adding a method that allows another object, the observer, to register itself. When the observable object changes, it sends a message to the registered observers. What those observers do with that information isn't relevant or important to the observable object. The result is a way for objects to talk with each other without necessarily understanding why.
interface Pampoo_GOF_IObservable
{
  function addObserver( $observer );
}

interface Pampoo_GOF_IObserver
{
  function onChanged( Pampoo_GOF_IObservable $sender, $type, $args );
}

abstract class Pampoo_GOF_AbstractObservable implements Pampoo_GOF_IObservable
{
    protected $_observers = array();	
	
	public function fireEvent( $type, $name )
	{
		foreach( $this->_observers as $obs )
			$obs->onChanged( $this, $type, $name );
	}

	public function addObserver( $observer )
	{
		$this->_observers []= $observer;
	}
}

Singleton

Some application resources are exclusive in that there is one and only one of this type of resource.
abstract class Pampoo_GOF_Singleton {
 
    protected function __Construct() { }
 
    private function __Clone() { }
 
    static public function getInstance($ClassName = null) {
        static $Instance;
   
        if ($Instance) 
            return $Instance;
        elseif ($ClassName)
            {
            $Instance = new $ClassName;
            return $Instance;
            }
        else 
            return null;
    } 
}