[wp-trac] [WordPress Trac] #37699: Death to Globals Episode #1: A Registry, A Pattern

WordPress Trac noreply at wordpress.org
Sat Oct 15 20:01:02 UTC 2016


#37699: Death to Globals Episode #1: A Registry, A Pattern
----------------------------+------------------------------
 Reporter:  wonderboymusic  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------------------

Comment (by jacobsantos):

 I was going to reply long form, but then I realized I agreed with your
 overall message and didn't want to nitpick the entire message and remove
 the point. I think part of the problem is that I think we probably all
 agree that something better should be used, but disagree on what exactly
 that is.

 I agree that focusing on globals at this point is most likely unwise. The
 problems with globals are not as extreme in a language as PHP. The reason
 I use such justifications is to support other better patterns. As you have
 said, the focus should be elsewhere and I think registry or service
 locator pattern should be included (per also my ticket) as soon as
 possible. Refactoring existing code to that would be much easier.

 I would recommend, given that Composer is also being backported, to
 backport an existing container library. It should have better support and
 less errors. When WordPress moves to later PHP versions, you should be
 able to move to the third-party library with minimal effort, provided the
 API is compatible.

 The reasoning I have used, is that registry or service locator or other
 inversion of control techniques (plugin, dependency injection, etc) allows
 for better more focused and isolated unit and functional tests. Being able
 to properly write integration tests should be the design focus and will
 help the user in the long run as the system will be more stable and they
 will experience less bugs as the system will eventually have better unit
 and functional tests.

 I would recommend acceptance tests for system as that might have greater
 gains in shorter time frame as it will obviously be user focused.

 I will not be providing any patches or helping WordPress in any way. It is
 my policy that it isn't the best use of my time. I will say again that the
 container libraries has created far better code in my fork and exceeded my
 expectations with how much better the code looks and functions.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37699#comment:110>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list