Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #32470, comment 1


Ignore:
Timestamp:
05/23/2015 04:06:21 AM (11 years ago)
Author:
jacobsantos
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32470, comment 1

    initial v1  
    1 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.
     1I 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, brah?" and the answer is no.
    22
    3  * Use interfaces.
    4  * Smaller independent classes.
    5  * Smaller interfaces.
    6  * Type hint interfaces or check instanceof.
     3Basically, SOLID, check Wikipedia. There are books as well.
     4
     5 * Use interfaces (allows dependency injection).
     6 * Smaller independent classes (Best Practice).
     7 * Smaller interfaces (Best Practice).
     8 * Type hint interfaces or check instanceof (Dependency Injection).
    79 * Attempt to move away from inheritance and more towards composition.
    8  * Don't ever, never ever. Never ever? Yes, never ever use static methods, unless you are creating a singleton.
    9  * 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.
    10  * Classes should be small.
    11  * Methods should be small.
    12  * Views should be in a separate file.
    13  * Classes should only contain unique code.
     10 * Don't ever, never ever. Never ever? Yes, never ever use static methods, unless you are creating a singleton (best practice).
     11 * 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 (best practice).
     12 * Classes should be small (best practice and Single Responsibility).
     13 * Methods should be small (best practice).
     14 * Views should be in a separate file (separation of concerns and best practice).
     15 * Classes should only contain unique code (Single Responsibility and obviously, best practice).
     16 * If the answer is "I could just extend this class to change the functionality." Then you are asking the wrong question. You are better off creating a new interface and moving the code you were going to add by extending to a new class and dependency injecting the class that matches the new interface.
     17
     18The end result will be greater amount of smaller classes with interfaces that describe functionality that can be called in functions and other objects. No object should reference a class by name, only check that the class implements interfaces.