[wp-hackers] Coding Standards: Functions vs. Classes

Braydon ronin at braydon.com
Sun Mar 18 01:14:32 UTC 2012


When 5.3 is the minimum requirement, using namespaces would give a solution.

So "set_transient()" would could become "WordPress::set_transient()" and 
within plugin and theme development we could be in the WordPress 
namespace, and still use the shorter "set_transient()". The benefit here 
is more cohesion between separate PHP projects.

It's more or less the same anyways.

On 03/17/2012 05:39 PM, Brad Touesnard wrote:
> It seems there's two competing views on whether a set of functions or a
> class should be used in core. For example, the relatively recent transients
> API is a set of functions, but could have just as easily been a class. Is
> there some reasoning behind the decision to use a set of functions instead
> of a class? Or is it coders choice?
>
> To be clear, I'm not for or against using a set of functions instead of a
> class. And the transients API is great the way it is. If there's no
> difference in performance, I personally don't care either way. However, I
> am for consistency and don't see a reason why we should use both techniques.
>
> And what about static class variables rather than global variables? WP
> stopped supporting PHP4 last year, so is there any reason not to use static
> class variables for new development?
>
> Maybe there's a wiki article I'm missing about this stuff? I did look at
> the WordPress Coding Standards wiki page (
> http://codex.wordpress.org/WordPress_Coding_Standards), but no luck.
>
> Cheers,
> Brad
> http://bradt.ca/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> !DSPAM:4f652ef8140311418750826!
>


-- 
Braydon Fuller
http://braydon.com/



More information about the wp-hackers mailing list