Writing clean code and its importance for web marketers
What is Clean Code?
As Robert C. Martin stated in his book (Clean Code: A Handbook of Agile Software Craftsmanship),
“Clean Code is code that has been taken care of. Someone has taken the time to keep it simple and orderly. They have paid appropriate attention to details. They have cared.”
Why is clean code so important?
SEO appropriateness is at stake
Another less known benefit of writing clean code is its contribution to SEO. Just as FusionBox points out, as a concept, search engine optimization is split in two essential directions.
The first one is “optimization”, which refers to the actions performed in order to make a site appear among the first results in search engines. This is mostly related to actions exterior to the website – backlinking via PR methods, social media distribution etc.
The second one refers to an “optimizable” website and represents the way a site displays essential information so that it has maximum visibility to the search engines.
This last part is impossible to accomplish by a human being, and that’s why all search engines use a crawler robot, or a “spider”, as it’s known in the SEO jargon, to determine which sites correspond to users’ needs on the web.
And because these “spiders” have eight eyes, they can’t see the webpage the same way a human eye does. That’s why it will “spin” its web around the HTML file of the page, where it can find all the information it needs and understands. That’s why the more you commit to writing clean code, the better search engine robots will understand your site and rank you higher among displayed results.
But these are not the only advantages of clean code when it comes to SEO. To see some more in-depth tips and places where it brings significant value, here is a piece written by the searchenginejournal. Even if it’s slightly outdated, it does outline that the concept of clean code should be the focus of your day-to-day work.
You’re working on developing your website. Or a landing page.
When you have WordPress or PHP developers working on your team, make sure you stress the importance of writing clean code.
Code is almost never written just once and then forgotten. Most of the times, when we develop a website, we deliver it to the client and have someone on their team look after it from then on. When a new person needs to work on the code that was written, they MUST understand it.
“If you want your code to be easy to write, make it easy to read” — Robert C. Martin
Writing clean code, that is easily recognizable by Google, may sometimes mean that your website will take more time before it’s ready.
The project manager will have to understand that taking more time to write clean code is better for the future, even if there is client pressure to stay within deadlines.
Trying to hurry up to the finish line will cause mistakes to occur that will slow you down in the future, when bugs will start to show up. You wouldn’t want to spend time fixing them in the middle of your web campaign.
“Clean code always looks like it was written by someone who cares. There is nothing obvious you can do to make it better.” — Michael Feathers
What does clean code mean?
Writing clean code, as Robert C. Martin stated in his book, can be defined by a single word, “small”.
Function and classes should be small and compact. It is much easier to make sure that a function works and does one thing if it is very small. When you divide the logic in many small functions, it gives you more opportunities to insert new code and to explain what is going on in each project.
Dynamic error information
When you throw an exception, you need to include as much dynamic information as possible in order to help with debugging and to make it easy for team members to discover potential errors.
Here is a scenario we often encounter: if you want to make a request to a server and you use http protocol instead of https protocol, you have to include some error handling messages in the headers, in order to know where the problem stems from.
Commenting on every step is useful so that you and the others understand what is written. I recently worked on a project and I completely forgot to write comments on the code. Consequently, it was hard for me and for my co-workers to understand what I was doing there and what needed to be added and where. Therefore, I had to take another look at the code to decipher it step by step and write comments. Repairing my mistakes took a lot of time and effort that I could have successfully avoided.
Writing clean code should become part of your ongoing strategy, the same way writing content and distributing it on social media should. There’s no reason why the lines of code behind your website’s (landing) pages shouldn’t be optimised for Google, just the way your content is. You will find it time-consuming, but the advantages will not fail to show up in the long run.
We recommend your programmers to go through Robert C. Martin’s Clean Code, before going into developing a new landing page. Your clients will thank you for it.