Home HomeMartin T. Bannister Department of the Treasury Blueprint for Actions (2009)Martin George R.R Gra o tron (SCAN dal 908)Gail Z. Martin Polegli królowie 01 ZaprzysiężeniMartin Gray Wszystkim, ktorych kochalemMartin George R.R Gra o tronAzazel (1988) Asimov IsaacCastillo Pamietnik zolnierza KortezaSheckley Robert Zbior opowiadanStrugaccy A. i B Lot na Amaltee. StazysciWalter Miller Kantyk dla Leibowitza
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • us5.pev.pl
  •  

    [ Pobierz całość w formacie PDF ]
    .First,consider its structure by looking at the code with most data removed, and the longermethods' code removed:class smartClassMapper extends cachedSingleton{protected static $instance = __CLASS__;protected $dynamap = array();protected $debug_log = array();protected $populating = false;protected $classmap = array ('aliroAbstractDatabase' =>'aliroDatabase','aliroDatabaseHandler' => 'aliroDatabase',);protected $extmap = array('PclZip' => 'pclzip.lib','Archive_Tar' => 'Tar');protected function __construct (){// Enforce singleton}public static function getInstance (){return is_object(self::$instance) ? self::$instance :(self::$instance = parent::getCachedSingleton(self::$instance));}public function __print (){return sprintf(T_('SmartClassMapper, %s dynamic items, %logs'), count($this->dynamap), count($this->debug_log));}protected function populateMap (){}public function getClassPath ($classname){}protected function saveMap ($path, $map){}}[ 62 ] Chapter 3Note that the class mapper inherits from the cachedSingleton, which is an abstractclass described in detail in the chapter on caches.The inheritance makes it easy tobuild a singleton class that will only be constructed infrequently so as to reducethe overhead of organizing data, and cut down on database access.Most times, thesingle instance of the class is retrieved from cache.Any number of variations is possible, but the scheme adopted for Aliro is thatcommonly used framework classes for the user (as opposed to administration)side of Aliro are stored in files that have the same name as the class apart from theaddition of the extension php.They are all held in a classes directory.There is nostored data in the mapper for these classes.Other class information comes from thearrays that are properties of the mapper:" dynamap: is filled with information about the classes that make up extensions.The universal installer takes information about classes from the XML file thatdescribes an extension, and stores it in the classmap table of the database.The dynamap table is filled up from the database by the populateMap methoddiscussed in detail below." classmap: is set with information as part of the development of Aliro, andrefers to the classes stored in the classes directory mentioned above.Wherea file contains more than one class, any class that does not share its namewith the containing file must have an entry in classmap.The array key is thename of the class, and the array value is the name of the file without thephp extension." extmap: refers to classes held in the extclasses directory of an Alirosystem.This directory is populated with classes taken from otheropen-source projects that have yielded valuable capabilities for Aliro.Tokeep the situation clear, the mapping of these external classes is kept separatefrom Aliro's own classes.Array keys in extmap are again class names, andthe values are file names without the php extension.Where necessary, thefile name can be preceded by one or more directory names, relative to theextclasses directory.Some PHP code goes to great pains to handle paths with backslashes for Windows,and slashes for Linux.This is unnecessary.It is tidier to be consistent, and fareasier to handle ordinary (forward) slashes.PHP sorts out the operatingsystem dependencies.Other properties of the Smart Class Mapper are the static instance variable that isused to hold the one and only object instance of the singleton class, and the debug_log array that contains an entry for every class that is loaded.As its name implies itis available for debug, or performance tuning.[ 63 ] Organizing CodeThe short methods that are shown in full in the code above are:" __construct: is invoked automatically when the singleton instance iscreated.It does nothing but declaring it as protected prevents the class frombeing created using new rather than through the static getInstance method." getInstance: is the only way to obtain a smartClassMapper instance.Itchecks whether an instance already exists in the class variable of that name.Otherwise, it enlists the aid of its parent class, the cachedSingleton, to try toobtain data from cache, or to create a brand new instance." __print: is provided to aid diagnostics, so that in any situation wherevariables are being printed out, the class mapper object is capable ofproducing meaningful output.Digression on the Singleton PatternAliro makes extensive use of singleton classes.They arise naturally in designingsystems where a range of related services is needed.Sometimes, this is done bycreating a class that consists only of static methods.But that is both inefficient, andinflexible.Dealing with an instance of a class is generally more efficient than dealingwith static methods, and in many cases a singleton object will know quite a lot ofpotentially complex information [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • syriusz777.pev.pl
  •