What is cowboy coding?
You might hear developers talk about cowboy coding. At it’s most general, cowboy coding is quick and dirty, with little or no planning or safety measures or testing. Cowboy coders are undisciplined and wild, and although they often get good work done fast, they can also cause some big problems. Here at WP Stagecoach, when we talk about cowboy coding, we specifically refer to coding on live sites.
Why is cowboy coding bad?
As long as everything goes without a hitch, cowboy coding can be just fine. Unfortunately, it is unusual for things to go without a hitch. There are several potential problems to coding on a live site:
- Site visitors will see the work in progress. Maybe on a site that doesn’t get much traffic, if you’re just making some minor changes, this doesn’t seem like a big deal. But you only have one chance to make a good first impression, and if new site visitors see broken site layouts or error messages, they will think you are, at best, unprofessional. And if it turns out that your “minor changes” get more complex than you thought, the site might end up looking awkward for longer than you planned.
- Untested code might not work everywhere. When you code on a live site, you only see the site in the browser you are using as you code. But that code might not work correctly in all browsers, and site visitors will see a broken site. It is better to take the time to test your code before you put it on a live site.
- White screen of death! Broken layouts and error messages are bad, but the white screen of death is worse. One tiny syntax error in a PHP file can cause the entire site to go down, leaving you with just a white screen. This is even worse if you are using WordPress’s built-in theme or plugin editor, because you can’t access the WordPress dashboard when you have a white screen: you must have FTP access to the site to fix this.
- Long-term development. Cowboy coding is one thing when you’re making just a tiny change that only takes a few minutes… But if you are making major changes, you really don’t want to do it on a live site. You don’t want site visitors to see a work-in-progress for several days or weeks.
Why WordPress developers are often cowboy coders
Unfortunately, WordPress makes cowboy coding easy. It’s so easy to just go to the theme editor or the plugin editor and start editing PHP files right in the WordPress dashboard. One of WordPress’s greatest strengths is the fact that it is easy to get started in WordPress development – a novice with CSS, HTML, or PHP can start tinkering and make changes to their site. But this also becomes a weakness, because people without knowledge of best practices often start out as cowboy coders.
WordPress also makes it hard to get around cowboy coding and follow best practices. Instead of developing on a live site, the better solution is to either create a copy of your website, or have a separate website that you use as a testing ground, perhaps on your local machine. This can be, at best, a hassle, and at worst, a frustrating time sink. It is painful to spend an hour making a copy of a site, just so that you can spend 10 minutes changing a page layout.
What we can do about it
The good news is that more and more tools are coming out to make it easier to follow best practices and avoid cowboy coding. One of those tools is WP Stagecoach, which makes it quick and easy to make a staging copy of your website so that you don’t have any excuses for developing on a live site.
No more cowboy coding!