----- Original Message -----
From: "Dennis Gearon" <[EMAIL PROTECTED]>
Newsgroups: php.general
Sent: Friday, March 16, 2001 2:42 PM
Subject: [PHP] Thoughts on Class libraries
> 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.
Pros and Cons
Pros
Persing required files result in minimum number of included files, it may result
in better performance.
Cons
Parsing and finding required files from scripts would requries CPU intensive
work, it may NOT result in better performance.
It would be nice to have a ability to include all class/function definitions
required by a certain scripts. However, I think programmer must control
include()/require(). If there are many files to be included and hit server
performance, I would consider to use script cache modules like, Zend Cache, APC
or bcache(?).
Besides, I think programmers should know which files are needed for a program
and PHP complains if there is no class/function definitions.
Although, this kind of approch works great for build system like autoconf,
libtool, etc. It is generally not a good idea especially for script language
like PHP.
(In some cases, this kind of approch works great with PHP also. For example, you
can implement abstruct database class as follows. Create abstruct database class
for 20 different databases, and you want to use the same class name for all
databases. You can make a class that defined only user interfaces and create
database spcific object as the class property. Each database has its own class
definitions and abstruct database class needs only one of them. In this case,
you can improve performance with your approch)
Sorry for the negative response.
Regards,
--
Yasuo Ohgaki
> 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)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]