What is Custom Code?
Custom code is any PHP code that is not in Drupal Core or in one of the publicly available Drupal modules. It is used by developers to create extra Drupal functionality and used to gap between what is technically available and what is missing.
Custom Code is unnecessary
If you want a certain functionality first do an extensive search on all the available Drupal modules. This can be tricky because someone can use different terminology to describe the same problem. So make sure you spend up to a few hours Googling your use case. Changes are someone else had the same issue and solved it with a module.
When this is not the case you should be wary. Maybe the functionality you want is so unique because it doesn’t make sense. Trying to make Drupal do things it wasn’t intended for can backfire. Go back and review why you want this specific function in your Drupal website. Might there be an easier way to do this? Or maybe another application or platform is more suitable? Think twice before plunging money into this piece of Custom Code.
Custom Code is expensive
Asking a developer to create, test and maintain Custom Code is expensive. Even the smallest Custom Modules cost around 2000 dollars. Which is justifiable because creating high quality Custom Code takes time, and you wouldn’t want it for less.
And if you think you just have to pay once and be done with it, think again. Every time Drupal has an update it can break the Custom Code. The developer needs to go in and fix it. This will cost money.
Custom Code unsustainable
Custom Code makes you dependent on the developer who created this piece of code. What happens if the code needs to be changed but the developer has moved on or isn’t available for a long period of time? You might end up with a broken website.
In theory it is always possible to let another developer take a swing at it, but most likely they will grunt at the code they get presented and will tell you it’s better to start from scratch. Which is fair, because it probably will be faster for them than to go through someone else’s code trying to figure out how they created the solution.
Compare this to an already available Drupal module which you can download and use for free. Every Drupal module has a maintainer who is responsible for bugs and feature requests. If this maintainer becomes inactive it is possible for someone else to pick up where they left. Everyone can report a bug or request a feature and multiple developers can look into a sustainable solution.
When you can’t avoid Custom Code
If you need to connect Drupal to another system, such as an internal CRM tool, it is impossible to avoid some Custom Code. The arguments above still apply, though. Is it really necessary to connect these systems to Drupal to sync data? If it only concerns a few instances every month maybe it’s something that can be done by hand. If it is a well known system there might already be a module available, so make sure to check that first.
Update: After posting this blog I got a few reactions and I feel like I need to nuance a bit. If you are a developer and you can create a solution writing 10 lines of Custom Code instead of using a couple of modules, then by all means go for it. This blog is intended as a cautionary tale for organisations wasting money on a small part of a Drupal website (Custom Code) where it could better be spent on other facets of the website. Let me phrase it this way: if the Custom Code costs more than a third of the total price of your Drupal website, there might be something askew making you reconsider.
How do you feel about Custom Code?
Let me know by leaving a comment. I'm interested to hear use cases where Custom Code is unavoidable or why Custom Code might be better than an existing module.