- Intent
- provide a simple interface to a subsystem.
- Motivation
- a complex system can have many parts that need to be exposed, but it could be confusing ergo - provide a simple interface to the system. For example a read-evaluate-print process of an interpreter
- Implementation
- Hide the construction of the required objects inside the facade
- Example
-
class rep_facade { function __construct() { $this->firewall = new firewall(); $this->reader = new reader(); $this->evaluator = new evaluator(); $this->printer = new printer(); } function rep($text) { $text = $this->firewall($text); $ts = $this->reader($text); $result = $this->evaluator($ts); return $this->printer($result); } } - Complications
- The lack of modules and/or nested classes in php means that this is a comfort interface, not an enforcing interface
Facade
by vlado on Tue, 2006-07-25 09:53- Printer-friendly version
- Login to post comments