[wp-trac] [WordPress Trac] #32470: Abstracting the Widget Classes

WordPress Trac noreply at wordpress.org
Tue Jun 2 13:26:54 UTC 2015


#32470: Abstracting the Widget Classes
------------------------------------+------------------------------
 Reporter:  welcher                 |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Widgets                 |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |     Focuses:
------------------------------------+------------------------------

Comment (by jdgrimes):

 Thanks for the explanation @jacobsantos. I'm starting to see better where
 you are going with this. I can grasp how this will improve the testability
 of the API. And I can also see now that you're not actually trying to
 rewrite the entire API, just to refactor `WP_Widget`. Ultimately it is the
 same thing as @welcher proposed in terms of scope, but you are reducing
 the complexity of the `WP_Widget` class itself, rather than increasing it.
 This actually gives us more freedom to reduce duplication across the
 widgets because we won't be tied to having just one all-encompassing
 abstraction in `WP_Widget`, we can have several different flavors of
 widget that implement these interfaces.

 >It is my prediction that if WordPress includes better OOP principles in
 the code, that programmers will become better object-oriented programmers.

 As someone you has learned PHP practices mostly from WordPress, I can say
 that the way I do OOP  is largely based on what WordPress does. If
 WordPress improves, so will I, and many others will too. However, there is
 a difference between growing my knowledge of OOP alongside WordPress and a
 newbie trying to break into WordPress development after the fact. I think
 if it *seems* too complex, it may discourage some people from getting in
 (not necessarily a bad thing, mind you). It took both me and @welcher some
 time to wrap our minds around it, but I think in some ways the end product
 will actually be simpler than what is was before, once a dev cracks the
 entry barrier. And, because backward compatibility will be maintained,
 newbies can continue to use the old approach until they better understand
 the new underlying API.

 ----

 Note: I see that you are using `static` in
 `WP_Widget_Display_Adapter::factory()`, however, WordPress still supports
 PHP 5.2 (not my fault :-).

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


More information about the wp-trac mailing list