Before code can be customizable, it must be clear. But clarity is not enough, if you're going to be using a codebase in multiple places.
Many open source projects excel at customization. People have enough different uses for an application that very few work perfectly out of the box for everybody. Most companies want to apply their branding to the software we use. Some people need an application localized and translated for their audience. Sometimes a company just needs a small change to make the software better fit their needs.
It's relatively simple to customize any application, if you have the source code. What becomes a huge challenge is maintaining your customizations when the underlying software is updated. If the software is not designed with specific ways of customizing it, it's going to end up being difficult to maintain, unless you have gotten your changes incorporated back into the original software.
Architecting for customization
Applications that are designed for customization have clear divisions of code. This can happen for several different areas:
- Templates or Themes. Most people want to be able to change the look and feel of a web application. If it has a template or theme system, you can just create a new theme and turn it on. Upgrades can then happen without clobbering your changes.
- Language. Most successful open source projects have separate language files containing all of the labels, instructions, menus, and other text the application shows. Many come with multiple translations, and accept others as people contribute them.
- Add-ons, plugins, modules, and components. Content management systems like Joomla and Drupal are particularly strong at this. SugarCRM is, too. They have a well-defined way of adding new functionality to the application, keeping it self-contained in a separate unit of code that a site administrator can manage through the interface.
- An override mechanism. Some programs make it easy to replace the default behavior with your own version. ZenCart does this well--you can take many different core files, copy them into a particular directory associated with your site, and change them to make it do what you want. Upgrades to ZenCart will still use your versions of the files, even if the underlying file changes.
When you're customizing an application, all of the other aspects of quality code apply to your customizations, as well as the original code. Your add-on is faster and more secure if you use the application's interface for retrieving data instead of including your own. Your add-on is more powerful, clear, maintainable, and reliable if it uses the application's defined ways of customizing it.
While not all open source is designed to be customized, it's a strong consideration we're looking at when we evaluate a project. So what do you do if you need to customize something that's core to an application?
Customizing software not designed to be customized
If you need to make changes to the core part of an open source project, you're setting yourself up for a maintenance nightmare. All active server software has updates. No program is perfect. Somebody, somewhere, will find a way to crack into it, and if you have business data or unethical competitors or disgruntled customers or employees, you will get targeted eventually. In the security community, people publish vulnerabilities to programs, so that they may be fixed. That means if you're using common software packages, somebody needs to maintain it.
If you're using software designed to be customized, and all your customizations are outside of the core code, this is not a major problem. A system administrator updates the core software, and if any of your customizations break, your developers update your customizations. However, if you had to make a lot of changes to core files, you're in trouble. You either need to re-implement the security fixes in your code, or re-implement your customizations in the updated code.
There are basically 3 strategies for minimizing these issues:
- Use strong source-code management tools to manage your changes as patch-sets, and re-apply them at each upgrade, rewriting sections that no longer work.
- Fork the project, and take over responsibility for managing your branch. You'll need to track the vulnerabilities in the parent project, and re implement security fixes in your own.
- Contribute your changes back to the original project, and persuade the maintainer to incorporate them into the main code tree.
When you look at these alternatives, clearly #3 is far less expensive for you than the other two--your customizations are no longer customizations, but part of the core software. This is actually how open source develops, and how you may change from being an open source consumer to an open source contributor.