The big picture
Everybody who codes has to find solutions to complex problems multiple times every day. And every time we do so, we learn something new. The personal code evolution is a rocketing curve. But only to a certain point as there’re as well tasks that we repeat from day to day: Loading files, hooking callbacks to their appropriate hooks, fetching translation files and adding textdomains and so on. And as WordPress has something like an API that is meant to be used we suddenly find ourselves in the situation where we repeat similar tasks again and again. And the only real problems we get into is our copypasta as we’re fed up by writing the same lines into each single piece of code. Then we start to think about what parts all our codes got in common – the most obvious is forms: users, posts, taxonomies etc. all need additional data. And then we start summing up all those common things and stuff them into a base class that we can extend upon. Eureka! we did it! The next step obviously is to abstract things further. We build one class to handle saving to the database, another one to handle different UI tasks… we know the story.
And then, a half year and 30 plugins later, when coming back to our first piece of code that extends upon those classes, we realize that we already changed that many things that other plugins stopped working. So we go back, refactor the class, go through different cases and realize that we can simplify and abstract further. And we realize as well that we got too many edge cases. Label above, label below, label on the side, label in a different table cell, label with classes, … again: we know the story. So we do a rough calculation how long we’d need to refactor everything that extends upon it and give up. Let’s go back, realize that there’re so many edge cases that we’d have to work on the whole thing for another week. And no one would pay that. So what are we doing now? Let’s just ship it! and write exactly what we need for this single case.
After we did write single case code pieces for quite some time, we get fed up by it again. Then we try to open source our base, hope for contribution and that everybody jumps on our train and helps to make the world a better place. And we fail. We fail because most developers got the exact same kind of base laying around and don’t want to drop their own code. Or they simply have been through this multiple times and have given up.
I don’t know at which point you are (I’d love to read it in the comments below), but I’ve started and given up multiple times by now. And my personal conclusion is that I’ll stick with OCP – or: One Case Plugins – and go down another route. If I can open source something and you want to contribute, I give you full access, like a triple A pass. This means two things for me and every participating developer:
- I loose full control, you get responsibility
- The project will live even if I stop participating
Way of the ronin
Did you ever try to build base plugins or shared plugin classes? How did it work out? Are you succeeding with it or have you already switched over to OCP plugins or themes? Would you rather contribute to someone else code or write your own?