PHP : Initialized vs static registry class in performance -
PHP : Initialized vs static registry class in performance -
is there big difference between initializing registry class , using static methods in performance ?
for example
class registry { private static $data; public static function set($key,$value) { self::$data[$key] = $value; } public static function get($key) { homecoming isset(self::$data[$key]) ? self::$data[$key] : false; } }
on other hand
class registry { private $data = array(); public function set($key,$value) { $this->data[$key] = $value; } public function get($key) { homecoming isset($this->data[$key]) ? $this->data[$key] : false; } }
is there big difference [...] in performance
no. main concern imminent violations of dependency inversion first approach. sec approach allow injection of registry object, improving testability , extensibility.
php class design-patterns design registry
Comments
Post a Comment