What is Reusable?
Lab: Making the Collapsible Content Plugin Reusable – Part 3
Video Runtime: 18:07
What does reusable mean to you? Why would you want to use it?
In software, the concept of being “reusable” means that you design your code such that you can reuse it project-after-project with minimal to no rework of the code.
Think about that. Imagine the time you’ll save when you have a library of pre-built, well-tested, and proven code modules. You can then load the modules and quickly build your projects.
But the key is: minimal to no rework of the code. That is what makes it reusable.
Why? Think about it.
If you pull in a snippet of code or some boilerplate, yes, it will speed up your development time. However, you have to change the code in order to make it fit the project’s needs. When you touch the codebase, you introduce the potential for conflicts, wonky behavior, and bugs. You are literally changing the code that you previously tested and proved it to work. In doing so, you increase your time and costs over the entire lifecycle of the project and code.
What do I mean by software lifecycle?
Software has a lifecycle from the time you build it through testing to deployment and beyond into support and maintenance. Each of these phases has a monetary cost to it.
As a professional, this is your career and/or business. You need to improve your workflow and design approaches to reduce your time and costs. In doing so, you increase your profitability. This is a profession and a business. Every single hour you spend on a project increases its costs and reduces its profitability. This needs to be a concern for you; else, it’s just a hobby or a part-time thing.
Code Building Strategy
Reusable code reduces your time, costs, and bugs. A strategy that I’ve used throughout my entire career is a modular and configurable design approach which I call ModularConfig or ModularConfiguration.
Code is pre-built and well-tested as modules. These modules stand alone as some feature or enhancement. Then you add modules to your project to build custom themes and plugins. Next, you configure what is different for this project.
Configuration means that you’ve pulled the project differences out of the codebase to allow each project’s specific implementations to be loaded. You configure what’s different and then pass it into the module.
This approach is a different mindset. You have to think about how to build your code in this fashion.
One example is to build a module that allows plugins to serve up templates and web pages while allowing the theme to override it. Another is a code generator that takes a configuration for your custom post type and taxonomy. It generates the labels and arguments for you.
In this lab, you’ll learn about this approach and see it in action as we convert our plugin to the ModularConfig approach.
Break. Go rest your noodle for a couple of minutes.
Episodes
Total Lab Runtime: 06:04:21
- 1 Lab Introductionfree 07:43
- 2 What is Reusable?free 18:07
- 3 Modular in ModularConfiguration Architecturepro 15:12
- 4 Configuration in ModularConfiguration Architecturepro 12:31
- 5 Creating Configuration Repositorypro 05:14
- 6 Planning it Outpro 12:26
- 7 Build the FAQ Custom Post Type Configpro 09:10
- 8 Loading the Config Filepro 04:29
- 9 Building Custom Post Type Generatorpro 12:24
- 10 Generate Post Type Supported Featurespro 16:41
- 11 Generate Post Type Labelspro 14:45
- 12 Test it Outpro 16:26
- 13 Custom Post Type Generator - Registrationpro 13:33
- 14 Rewrite Rulespro 14:05
- 15 Reusable Rewrite Rules Handlerpro 08:15
- 16 Custom Module - Embed or Standalone?pro 07:22
- 17 Build the Topic Taxonomy Configpro 06:58
- 18 Reusable Taxonomy Generatorpro 10:19
- 19 Auditing the Custom Labelspro 18:10
- 20 Refactoring the Label Generatorpro 09:32
- 21 Specify Certain Labels Optionpro 10:10
- 22 Link the FAQ into the Taxonomy Generatorpro 10:28
- 23 Move Config to FAQ Modulepro 04:58
- 24 Test the Taxonomypro 13:30
- 25 Plan out the Shortcodespro 09:25
- 26 Starting the Shortcode Boilerplatepro 14:53
- 27 Build the Shortcodes Configurationspro 15:30
- 28 Registering Shortcode with Custom Modulepro 18:54
- 29 Shortcode Configuration Storepro 08:25
- 30 Test the Shortcodespro 11:32
- 31 Wrap it Up, Review, and Commit Changespro 13:14