[wp-trac] [WordPress Trac] #37699: Death to Globals Episode #1: A Registry, A Pattern
WordPress Trac
noreply at wordpress.org
Mon Sep 5 06:33:07 UTC 2016
#37699: Death to Globals Episode #1: A Registry, A Pattern
----------------------------+------------------
Reporter: wonderboymusic | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.7
Component: General | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
----------------------------+------------------
Comment (by jacobsantos):
@MikeSchinkel I would like to see what your implementation would be. I
know you have your library and it is nice. Does wondermusicboy know about
it? I would like to see what you mean in a patch?
My interest in this ticket is merely a curiosity, since I do not intend to
contribute any code for reasons. My own fork and experiments seem to
prove, at least anecdotally and to myself, that the registry pattern
combined with facades makes for extremely powerful and simple code. It is
much more clean and the concerns are better separated.
I think that Laravel does enough right while attempting to be as simple as
possible, that I would rather imitate it at this point. Or at least up
until the evolution of code proves a better way. I also don't understand
why functions couldn't also be provided for the archetypes or programmers
that may not understand OOP or just don't want to deal with objects.
What is wrong with `wp_service_wpdb()`? or
`wp_service_wordpress_version()`? These functions exist only to return
`WP::service( 'name' )`. Sure, you will have a lot more functions added,
but these functions don't really do anything, so they would be short and
testing them would be relatively simple. Just check that when the service
is registered, they return the object you are looking for or if the
service is not registered, they don't.
Functions, if done right, could allow for a functional paradigm
composition, which would allow for beautiful construction of building
solutions. I am still experimenting with this concept, so I don't have any
conclusion. It is more that creating functions that could be composed is
difficult. That and using objects with static methods relieves some of the
usefulness of using functions by themselves. I believe Laravel also
provides functions that forward to static methods. The documentation only
describes the functions, so they are more likely to be used in user code
-----------
I don't want to discount your experience, even if it conflicts with my
beliefs. As much as I would like to believe novice programmers would
overcome obstacles given enough time and training. I have known enough
people that lacked the intelligence or fortitude to raise above the
challenge.
At a certain point, the blame for the student not learning has to be put
at the teacher and the methodology employed, until all known methods of
teaching and explanation are exhausted. I figure I am just a terrible
teacher and part of the reason I don't completely buy-in that novice
programmers would be too stupid to put two and two together. Sure some
might get some odd number, especially at first while it is still new, but
I don't think much of the fundamentals are necessary to eventually
conclude 4. Even for the most dense of pupils.
If you say that people have problems with `::`, then I will take your word
for it, until further evidence proves otherwise. I think with most things,
a beginning programmer just has to accept that `ClassName::methodName()`
just works like `functionName()`, except that there is some weird
characters in the signature. For the most part, I would just not explain
it. When did a theme author care what they were copying, as long as what
they were copying just worked?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37699#comment:82>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list