Thoughts on Class libraries

From: Date: Fri, 16 Mar 2001 05:47:20 +0000
Subject: Thoughts on Class libraries
Groups: php.general 
Request: Send a blank email to php-general+get-44209@lists.php.net to get a copy of this message
In talking about PEAR and PHPLIB, the subject of large class libraries came up. So in response to this problem, I had this idea. I'd like to get some feedback on it. Every script includes a simple parsing function from the 'prepend.php' file at the very top of the script. This function causes the script being loaded to **parse itself**. It finds all the 'new' statements, to make an array of needed class names. Only the executing file would would parse itself, all the classname files and classname extending files would could only include any parent object file, and NOT the parsing function file. <implementation-1> The parsing function includes the correct file by just adding '.php' to the end of the class name. This would require: A/ One class per file B/ the class name same as the class <implementation-2> Classes are in libraries that are named after the prefix of a SET of classnames. The library file is included which has the bare name of the 'prefix.php'. <implementation-3> Classes have little 'ghost files.php' which are just just an 'include once' statement for the relative library. The first time the library gets included, it appends all the class names it holds to an array in the parent script. The function checks that array for relevant classnames before reopening the 'ghost.file' and reopening the 'libraryX.php' file. <implementation-4> The classname<>library list is in a master library file, parsed into an array first off in the function. The parsing function first queues up classnames needed, then checks the names in the master list, erroring out if desired, then queues up the appropriate libraries to include, then includes them. <implementation-5> An extension of number 4 above. You give the parsing function the class/class library path, and for any classes it doesn't find in the master list (table), it goes through the libraries looking for 'class' statements and updates the list. If you happen to be the unlucky user who loads a page when that happens, it sends a timed redirect page back to the original page with a message with the (typical user) mind blowing message, "You have triggered an automatic self improvement process on our server! The server is adjusting it's performance to your requirements. Thank you, and HANG ON! You will be rewarded with a reload of the page you requested and a faster site! Thank you for helping us! Reload will occur in '10', '9', etc....." It's be good if you could make this an 'in memory table or file'. <?php-----------?> FINAL RESULT FOR ANY IMPLEMENTATION: A/ You would never have to worry about what file to include the class from. B/ You could limit the amount php included. C/ Depending on the implementation, you could limit the number of php, file opening, and use also class libraries. With good grouping, this would let a minimal amount of included php/file operations happen. -- ________________________________________________________________ Sites by friends of mine: http://www.myhiddentreasures.com/ ________________________________________________________________ WARNING personal propaganda signature TAKE WHAT YOU LIKE AND LEAVE THE REST SINCE OUR GOVERNMENT WON'T PRESERVE OUR CLIMATE, IT'S UP TO US! Imagine ** yourself ** and your kids now an endangered species <1>Inflate automobile tires to near maximum in summer, -2psi in winter <2>add insulation to house and hot water heater, and refrigerator, <3>combine trips in cars, make less of them <4>buy cars, sports vehicles and recreational vehicles with good if not best mileage <4>put awnings over windows is summer, remove in winter. <5> add solar hot water heating. <6>Push for energy recycling clothes dryers <7> walk more, play outside with your kids! <8> let your grass grow to 3-4 inches, chokes weeds, saves water and energy, keeps house cooler <9> Put WHITE or REFLECTIVE materials on roofs to send energy back into space. <10> Vote for burial of logging slash onsite in logging areas for better watersheds and less burned vegetation. <11> compost your leaves and grass, bury in flower beds, lawns, gardens, or give away. <12> VOTE for energy and CO2 ratings on ALL products and foods. KNOW how much damage your purchases do to the climate. <13> Give your kids less stuff and more of you. <14> recycle everything you can <15> limit your children to an average 1 per adult between all your marriages. (Only REPLACE yourself, not expand the population)

« previous php.general (#44209) next »