OOP and API first #25
Replies: 2 comments 1 reply
-
I've plonked bits of OOP into some of the things I've done. If you check out the Table Tents, for example, you can see some classes. Another example is the Schedule layout (that appears under "Schedule" -> Current Schedule) But the scope of that OO code has been narrow, to date. I'm in favour of more OOP, especially if we can start encapsulating common bits of logic. |
Beta Was this translation helpful? Give feedback.
-
I love the idea of moving to more object oriented code. And I understand it theoretically, but I've not really used it much in PHP (or in my day job which is really old school code). |
Beta Was this translation helpful? Give feedback.
-
At present I don't think there's any object oriented code in Zambia/PlanZ (there's probably a little in external dependencies, but I'm not aware of any in the core project).
So I wanted to sound out this idea before starting implementation.
I would like to see us move towards a more object oriented model, with classes defined for common application elements. For example there could be a Participant class. Pages that use Participants would request an instance for the needed participant, then manipulate the participant through properties and methods.
We could take this further and wrap a very simple API layer around the class. This could potentially allow alternative front ends, such as a mobile app, or a React JavaScript interface. The "API First" approach is to build APIs for everything from the outset, so we're ready for external interfaces to consume them.
Now I don't think we should embark on rewriting all of the current project as classes. However, for any new entities being added to the project, we should at least discuss it.
I think the Links feature I'm looking at could be a good test case for this, as it will consist of a couple of relatively simple classes, and could be relatively self contained. It wouldn't commit us to following this approach for anything else, but it would give us a foundation to build on if we decide to go that route.
However, I though I should seek feedback on the approach before I start implementation. If there's strong opposition to any OOP code in the project, I'll certainly reconsider.
Beta Was this translation helpful? Give feedback.
All reactions