[wp-trac] [WordPress Trac] #32468: Add Registry Class as WP_App
WordPress Trac
noreply at wordpress.org
Fri Dec 11 15:39:07 UTC 2015
#32468: Add Registry Class as WP_App
--------------------------------+------------------------------
Reporter: jacobsantos | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Resolution:
Keywords: dev-feedback early | Focuses:
--------------------------------+------------------------------
Comment (by jacobsantos):
You need a registry to exist, so that classes may start to use it. You
need classes that use a registry in order for the registry to exist. That
is an interesting problem.
'''Note:''' I use "unit tests" below. What I mean is the testing and
running a single unit at a time. Not the current WordPress test suite
known as "unit tests" which weren't unit tests.
Replying to [comment:4 ericlewis]:
> Hi @jacobsantos, thanks for your proposal! The registry pattern is
chill, although, as you've hinted at, jamming it into WordPress without
obvious, practical gains is going to be a non-starter.
No, I'm pretty sure I listed practical gains that were not obvious. If
they were obvious, the pattern or a similar or more advanced pattern would
already be in WordPress. The problem is that writing unit tests produces
code that is unit testable. Unless you care and write unit tests often,
then the gains won't be obvious.
>
> This would probably be better to consider when we're building out new
functionality, rather than as a blanket proposal.
If the environment is using globals for everything, then when will you
move from globals? The proposal was part of a push to move WordPress to
use better code that is more testable.
>
> You mention
>
> > As globals can be replaced now anyway
>
> how can globals be replaced without breaking everything?
Exactly. A plugin could replace a global and either break everything or
change the behavior. It is also possible to replace a global that is an
object with a partial implementation that works for the developer, but
crashes on a client.
Using a registry along with an interface would provide for a way to ensure
that all available methods exist for an object. Without having to result
to the wasteful `if method exists` conditions.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32468#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list