[wp-hackers] Re: 2.0.10 and 2.1.3 Release Candidates

Sabin Iacob iacobs at m0n5t3r.info
Sat Mar 17 19:25:30 GMT 2007


Timo Kissing wrote:
> Instead of one big function I would prefer one (static) class with
> several (again static) methods, so you would use wp_escape::js($string),
> wp_escape::url($string) etc. This way all the functions are kept in one
> place, but it's easy to change one without messing with code that
> effects the others - and you avoid large if...elseif...else blocks.

...and you can also have a dispatcher that calls self::whatever, with 
whatever in (js, url, mysql, and so on)

>  WP in my opinion make much more use of OOP anyhow 

that's rather modules/namespaces-like functionality than OOP; and it's 
much more useful than OOP in this case, too :)

> (and strictly confirming
> to a "one class/one function per file" rule would not hurt either, but
> instead make "messing" with the core and updating later much easier).
>   

one class/namespace/module/whatever != one function; hundreds of files 
with one function each are as hard to maintain as one file with hundreds 
of functions (actually harder, due to having to search for text in 
several files while looking for something, and having to have several 
files open when moving code around);

+ 1 for related functions gathered in classes (should I understand that 
a patch doing this would be accepted? :))
+ 1 for one class per file



More information about the wp-hackers mailing list