How to Design Software — Plugin Systems
Learn how I made a chatbot extensible by designing and building a plugin system to make it modular.
Learn how to build a plugin system to allow others to extend your program’s functionality and modularity, using a chatbot as an example.
When I was younger, I had a top-of-the-line gaming computer. I spent thousands of hours playing games like Team Fortress 2, Minecraft, Guild Wars, and Age of Empires.
One of my favorite activities after I had thoroughly explored a game was the practice of modding. Modding allowed you to create or download packages of software that changed or added to how the software behaved — new levels, textures, or even game mechanics! The possibilities were limitless.
Now that I’m a software developer, I have a better understanding of how many of these programs supported such massive extensibility.
They used a concept called plugins.
Plugin systems
Plugins allow you to write subprograms that then hook into or are attached to a larger program. These subprograms then run, modifying or adding to the behavior of the running program.
In order to write a plugin, the program itself has to be written (or hacked) to support the plugin. Once this capability exists, you can “plug and play” tremendous amounts of functionality.
The Concepts
Plugin systems come in many shapes and forms — to illustrate the design, the following basic concepts can help frame your thinking:
The program
The first piece is the program itself, the thing whose behavior you are actually trying to enhance or modify. This might be a game like Skyrim or it might be a business application like Sketch. It might even be your own program!
Whatever it is, it offers some set of behaviors and capabilities that you want to change. More importantly, it does not know about the changes you want to make.
The hook
Something in the program you’re trying to change has to run the code it doesn’t know about. Otherwise, it would be very difficult to change the behavior.
Keep reading with a 7-day free trial
Subscribe to Joseph Gefroh to keep reading this post and get 7 days of free access to the full post archives.