[wp-hackers] Adding wp-includes/class folder

Jacob Santos dragonwing at dragonu.net
Fri Aug 31 12:58:19 GMT 2007


I don't fully understand the concept myself, but supposedly, one 
advantage to keeping everything in one file is so that opcode caching 
would not need to check includes for dependency before caching.

The example given is that ClassA extends ClassB, but included like this.

include 'ClassA.php';
include 'ClassB.php';

When the PHP compiler gets to include 'ClassA.php' and passes it off to 
the opcode cache, the opcode cache doesn't know what to do with it, 
since it doesn't have ClassB.php. Until it has ClassB.php it can not 
opcode cache ClassA.

Although some say it is a little bit slower, the decrease is only once 
and once the two have been cached, the decrease will be gone 
(conjecture). Other problems occur with if statements when including. 
Developers of Opcode caching would recommend including everything that 
you need, like in C and C++ (Rasmus interview on Opcode caching).

Jacob Santos

Stephane Daury wrote:
>
> Not a debate, but an agreement on my side.
>
> But can you develop on the loss of Opcode Caching?
>
> Stephane
>
>
>
> On Aug 30, 2007, at 23:17, Jacob Santos wrote:
>
>> What debate could there be for adding a class folder to wp-includes? 
>> I know the current standard is to have 'class-whatever.php' file to 
>> wp-includes folder. This would allow for better convention and 
>> organization moving forward. I mean this for external developers.
>>
>> One disadvantage is that developers would have to browse through 
>> multiple directories to find the current file. This setup is 
>> confusing to beginners and well everyone that isn't intimate to the 
>> code. Another disadvantage that using the PEAR convention you lose 
>> *perceived* *initial* Opcode Caching speed boost.
>>
>> The advantages are
>>
>> 1. Easier to unit test, can remove classes from presentation files.
>> 2. Also keep the class model separate from application logic.
>> 3. Using the PEAR convention, you would be able to use __autoload() 
>> on PHP 5.
>> 4. Easier to extend later (once the convention is established, any 
>> new classes can be applied).
>> 5. Simplifies more root WordPress files.
>>
>> I suggest keeping the functions where they are and just separating 
>> the classes into their own file, so you would have 1 class per file, 
>> instead of cramming as many classes as there in that feature in a 
>> single file. Using Dashes to represent folder paths, so 
>> wp_xmlrpc_server would be /wp-includes/class/wp/xmlrpc/server.php. 
>> Would also suggestion using Pascal naming convention for class names: 
>> WP_Xmlrpc_Server or ABSPATH . WPINC . '/class/WP/Xmlrpc/Server.php'.
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list