open in the way that we work with and collaborate with others in the industry, in how we listen to customers, and in our approach to the cloud. We contribute to and partner with open source communities and promote interoperability to make it easier and less costly for customers to develop and manage mixed IT environments. We actively participate in the standards setting process and support established and emerging standards in our products. In the cloud, we support key standards that provide the building blocks for open, interoperable cloud services, and we support developer choice of programming languages. We support data portability and believe customers own and control their data, no matter where it resides. donderdag 25 april 13
new HtmlEntititesDecorator($client); $client = new ParagraphDecorator($client); // Later in your code, and possibly in multiple places print $client->getData(); donderdag 25 april 13
argument the // name of the class to produce public static function getInstance($driver) { // Attempt to include the the file containing the class // (not necessary if you use a custom autoloader) if(include_once(dirname(__FILE__).'/drivers/database_'. $driver.'.php')) { // Build the name of the class, instantiate, and return $driver_class = 'Database_'.$driver; return new $driver_class; } else { throw new Exception('Database driver not found'); } } } // To use, call the factory's static method: $db = DatabaseFactory::getInstance('MySQL'); donderdag 25 april 13
single instance of the class private static $instance; // The constructor is private so that outside code cannot instantiate private function __construct() { } // All code that needs to get and instance of the class should call // this function like so: $db = Database::getInstance(); public function getInstance() { // If there is no instance, create one if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c; } return self::$instance; } // Block the clone method private function __clone() {} } // To use, call the static method to get the only instance $db = Database::getInstance(); donderdag 25 april 13