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

WordPress Trac noreply at wordpress.org
Fri Jun 12 15:52:02 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 jacobsantos):

 I was informed by nacin on slack (do I need a link, I probably do) that
 none of the proposals I have submitted will be accepted. I am guessing
 this includes the architectural changes included in the prototype patch I
 submitted in this ticket. I am also guessing that it is irrelevant whether
 or not unit and integration tests are included or if the current system
 tests are extended.

 I will continue my work on my fork and hopefully at some point down the
 road it will be included. At least it will be a better basis of what I'm
 attempting to describe and hopefully prove that such refactorings are
 possible without breakage and prove that refactorings allow for better
 code and less bugs at the same time.

 Or I might just discover that I was wrong. It is a possibly that I am
 wrong, but I do have enough anecdotal evidence to suggest that what I
 proposed is the way to go for better tests and maintainability.

 I am not even certain if it is just because I proposed the changes or if
 you would even be allowed to implement what I propose. If you can take
 what I wrote and apply it to your changes, then perhaps it might serve as
 a launching point for improvements into WordPress. I think the caveat, is
 that if the architectural improvements have a good reason for being
 implemented, it could be accepted.

 My goal and changes are out-of-scope with this new information. Do what
 you will, I will not be part of this discussion from this point. Given the
 amount of work I have already put into refactoring WP_Widget and
 everything, I am guessing that I will be working on it soon and if you
 would like to know more about what I proposed I can send you a link to the
 experimental library.


 Replying to [comment:28 jdgrimes]:
 > Replying to [comment:27 Frank Klein]:
 > > The proposed patch by @jacobsantos seems interesting, but it also is a
 lot of code movement. This means that it probably won't make it into a
 release very fast, as a lot of testing would have to be done.
 >
 > I think @jacobsantos intends to maintain full backward compatibility.
 And I think that he's also committed to writing unit tests and integration
 tests, since that is part of the reason he is proposing these changes. But
 yes, it will still certainly need lots of testing.
 >
 > > Also when working on new abstractions, we need to keep in mind which
 classes and methods are currently public. We would need to ensure that
 some form of backwards compatibility is maintained, because currently
 nothing keeps developers from directly accessing this code in their
 projects.
 > >
 > > In the meantime, I think we could have tangible benefits by doing
 smaller changes, like for example:
 > > - Making `WP_Widget` an abstract class.
 > > - Marking the methods that need to be overriden as `abstract`.
 > > - Marking functions that should not be overriden as `final`.
 > > - Marking private functions as `private`.
 > >
 > > Like that we could progress while working on a larger refactoring.
 > >
 > > Why not keep this ticket around for the larger overall planning, and
 have a ticket with a smaller scope to go along with #23012, focussing on
 improvements to `WP_Widgets` and `WP_Widget_Factory` that can be done
 right now.
 >
 > None of those changes are backward compatible (though for some we could
 employ hacks to make them more so). I think when this larger refactoring
 is complete, most of those changes won't matter anyway, because many of
 the old methods will probably only be there for back-compat anyway. So it
 might not be worth the time to do most of them. There might be other
 incremental improvements that could be made, though.

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


More information about the wp-trac mailing list