terminal-auspicious

Topics

programming

php drupal scheme scheming macros design patterns da la

design

design css

random thoughts

scribbles

alter ego

other me 'em that link us my space me linked in

Collections

Programmable web
PHP design patterns

PHP Design Patterns

  • A catalogue of php design pattern shorts
    • Accumulator passing
    • Closure
    • Control abstraction
    • Coroutines (generator based)
    • Dynamic dispatch
    • Dynamic loading
    • Facade
    • Factory and Abstract Factory
    • Fluent Interfaces/ Method chaining
    • Generator (iterator protocol based)
    • Generic function
    • Hooks
    • Interpreter
    • Iterator (based on protocol method)
    • Lazy evaluation
    • Memoization
    • Nested scope
    • Observer
    • Partial Evaluation
    • Protocol method
    • Proxy
    • Singleton
    • State
    • Strategy Pattern
  • Models, records, databases, friends and foes

Similar things

  • Learning lessons from Lisp or patterns and languages in PHP
  • Emulating closures in PHP
  • Some ways to use saved state with closures in php
  • Scoped php functions or more ways to abuse php
  • PHP Design Patterns
  • Strategy Pattern
  • Memoization
  • Singleton
  • Factory and Abstract Factory
  • Facade

guild
Home » PHP Design Patterns » A catalogue of php design pattern shorts

Interpreter

design patterns | php
Intent
given a language, interpret sentences
Motivation
request (path) parser in a web application
Implementation
  • a class for each expression type, interpret method for each type
  • a class and object to store state (context)
  • each expression class is resposible for building it's own parse tree
Example
class tag { //ts is the current token stream //this is a variant of partial evaluation var $args; function __construct( &$ts) { while( not_class($arg = next($ts)) ) { $this->args[] = $arg; } } //evaluate the function run( &$context) { ... } } //example usage $ts = array("tag","php","design patterns"); $op = current($ts); $prog = new $op(); $prog->run( new context() );
notes
  • the expression types can be possibly parametrized if their run an construct methods follow, particular 'typical' shapes
  • not_class is a language dependent function
‹ HooksupIterator (based on protocol method) ›
printer-friendly version | add new comment
thanks
Submitted by lida (not verified) on Wed, 2009-06-10 12:04.

"class tag { //ts is the current token stream //this is a variant of partial evaluation var $args; function __construct( &$ts) { while( not_class($arg = next($ts)) ) { $this->args[] = $arg; } "
always love code
___
lida diyet zay?flama r10seoogle

reply
Home » PHP Design Patterns » A catalogue of php design pattern shorts

dikini.net

spreading confusion by accident since 1970