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

WordPress Trac noreply at wordpress.org
Sat May 23 03:56:34 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:               |     Focuses:
-------------------------+------------------------------

Comment (by jacobsantos):

 I recommend not doing it any existing way in WordPress. I die a little
 every time I read WordPress code. It is like, "Do you even OOP?" and the
 answer is no.

  * Use interfaces.
  * Smaller independent classes.
  * Smaller interfaces.
  * Type hint interfaces or check instanceof.
  * Attempt to move away from inheritance and more towards composition.
  * Don't ever, never ever. Never ever? Yes, never ever use static methods,
 unless you are creating a singleton.
  * If the question is, "Should I use a singleton?" The answer is no. If
 the question is, "Are you sure I shouldn't use a singleton?" The answer is
 still no. If the question is still, "I think I should use a singleton."
 then okay, you obviously know what you are doing, so go ahead.
  * Classes should be small.
  * Methods should be small.
  * Views should be in a separate file.
  * Classes should only contain unique code.

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


More information about the wp-trac mailing list