![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
design patterns
robert_zhai
Life is short, cherish what we have owned !
My github is https://robertzhai.github.io 。
展开
-
Decorator
//The Decorator Pattern provides a flexible alternative to subclassing. Decorator allows you to modify //objects dynamically, adding capabilities without causing an explosion of subclasses interface原创 2012-12-23 22:47:25 · 256 阅读 · 0 评论 -
Proxy
//The essence of the Proxy is to hold a reference to the subject object in an instance variable and to //pass method calls on the Proxy class down to the subject. //Lastly, your Proxy class must pro原创 2012-12-23 22:50:05 · 252 阅读 · 0 评论 -
Active Record
//the Active Record pattern is the simplest of the database-related design patterns. The //Active Record pattern embeds the knowledge of how to interact with the database directly into the class perf原创 2012-12-23 22:57:17 · 276 阅读 · 0 评论 -
Monostate
class Monostate { // 属于类不属于对象 private static $_val = 0; public function Monostate(){ } public function set($val) { self::$_val = $val; } pu原创 2012-12-23 22:55:41 · 357 阅读 · 0 评论 -
mvc
mvc可以扩展为mvcd,这个d是用来扩展m的原创 2012-12-23 22:53:43 · 216 阅读 · 0 评论 -
Singelton
class Singelton { private static $instance = null; private function Singleton() { } // 不让克隆 private function __clone() { } public static原创 2012-12-23 22:52:37 · 346 阅读 · 0 评论 -
Observer
//The Observer is a collaboration between an Observable class (the subject) and one or more //Observer classes (the clients). The Observable class allows Observers to register with it. Then, whenever原创 2012-12-23 22:49:13 · 245 阅读 · 0 评论 -
adapter
// v1 class HwLib { function hello() { return "hello"; } function world() { return "world"; } } */ // v2 class HwLib { function greet() {原创 2012-12-23 22:46:51 · 263 阅读 · 0 评论 -
value object
//1. Protect the attributes of a Value Object so direct access is forbidden. //2. Set the object’s attributes in the constructor. //3. Provide no “setter” functions, which otherwise allow attributes原创 2012-12-23 22:55:15 · 300 阅读 · 0 评论 -
strategy
abstract class CacheWriter { abstract function store($file_handler, $value); } class StringCacheWriter extends CacheWriter { function store($file_handler, $string) { $原创 2012-12-23 22:52:04 · 250 阅读 · 0 评论 -
Factory
class Factory { private $_store = array(); function __construct(){ } public function get($key) { if(isset($this->_store[$key])) { return $this->_store[$key];原创 2012-12-23 22:48:09 · 231 阅读 · 0 评论 -
Registry
//one to find the Registry and one to //find the object associated with the key. class Registry { public $store = array(); public function is_valid($key) { return array_key_e原创 2012-12-23 22:54:16 · 272 阅读 · 0 评论