Wikipedia puts it best when it describes a software framework as “a standard way to build and deploy applications”. If we take 10 random plugins from the WordPress repository and compare them, regardless their differences, there will be some similarities:
- They (should) all check that the WordPress and PHP versions present are satisfactory.
- Some of them define their own helper functions to perform the same relatively simple, repetitive tasks.
- Most of them will implement some sort of mechanism to output notices for administrators, check for other dependencies like PHP extensions or other WP plugins, or register their settings fields.
… and the list goes on. The point is, even among a selection of random WordPress plugins, there will be some overlap in functionality. Some will overlap more, some less, but some overlap is there.
What that means for us
That means that if we build 10 plugins, our own 10 plugins will have overlapping code for these repetitive tasks. Moreover, they will also have overlapping code in building the overall plugin class structure.
At its best, there would be lots of repetition in our code. At its worst, there would be considerable overhead in keeping all of this duplicate code updated and bug-free across all of our plugins. And the more duplicate code you have, the likelihood increases that the human factor builds in bugs by mistake, e.g. through silly copy-paste mistakes.
The last thing we want are bugs — worse yet, bugs that our customers would find! Keeping all the code of these repetitive tasks in a central location was the logical thing to do. It wasn’t even the first time we’ve done that!
So what is a framework?
By using a framework, we can ensure the same code quality and build logic throughout all of our WordPress plugins. Furthermore, bugs discovered in the reusable parts of the code need only be fixed once to be fixed across all of our plugins. And it keeps the learning curve of tinkering with our plugins’ code minimal — once you’ve worked with one, you know exactly how the others are likely to work!