wp-parsely
wp-parsely copied to clipboard
Refactor all endpoints code
Is your feature request related to a problem?
Our endpoints code is (maybe unnecessarily) scattered across files, has multiple levels of inheritance, and is generally complicated to follow/debug for contributors. As we keep adding more and more endpoints, this situation will only get amplified.
We need to refactor our endpoints to have code that is simpler and more maintainable in the long run.
Describe the solution you'd like
- Plan
- Look at the existing code. Brainstorm and take notes on how it could possibly be refactored/simplified.
- Discuss the ideas and take any feedback into consideration.
- If needed, before, during or after the discussions, work on some proof of concept code to help conclude the feasibility or to visualize how the end result could look like.
- End-up with a final approach.
- Implement
@vaurdan, tagging you here for notifications, in case you're not receiving any from this thread.
I think there could be 2 main approaches here:
- Attempt to restructure everything from scratch.
- Simplify specific aspects of what we have step by step, until we end up with something simpler.
I'd probably suggest option 2, but happy to hear if there are different opinions.
Things to think about, in no particular order:
- Currently our code is split among 2 files/classes (Endpoint + Remote API) in most cases. Is this differentiation useful, and does it simplify or complicate things for us?
- We have at least one class that inherits from another class, while also extending an interface. Can we simplify that?
- We might have interfaces that get implemented only in a specific file. In this case, maybe it's worth removing the interface?
- Permission handling has become complicated, might have multiple levels. See if there are ways to handle this in a simpler way.
- Are there other ways we can simplify the code without creating duplication, or at least too much of it?
- If we think it's needed, are there any simple design patterns that we could use?
There might be other things I've missed, let's put them all together in this thread.
There's also an effort and private conversation to make PCH work with WordPress.com, which involves some tinkering with the endpoints.