Think before you code!

Antonija Dimoska
Codeart
Published in
3 min readApr 10, 2019

We all know how frustrating and time-consuming it is to solve a hard labyrinth, especially a huge one with many obstacles.

Now imagine, you are a front-end developer and you need to work on someone else’s code.

  • Someone who didn’t write clean code.
  • Who used !important whenever they felt like it.
  • Targeted elements by their ID.
  • Nested classes all the time.

And now, it is YOUR job to clean that code and possibly add style for a new feature or fix a bug.

You start coding and you are stonewalled from every side because the previous coder overrode everything and the nesting is two lines long. Wouldn’t you feel like you are going in a labyrinth — like the image above and dread the moment you start working on it? Even curse the previous coder?

Now, if you are writing clean code, WELL DONE and this article isn’t for you. This post is for those who are always in a hurry, who don’t want to waste unnecessary time (which is quite counterproductive) or those who don’t listen to advice from fellow developers because they know best.

Being a front-end developer is like being an artist.

  1. You need to visualize the project from the start, which element you are going to need at some point in time.
  2. Then write your plan, on your computer or in a notepad. Note which elements are repeating.
  3. Then start writing your css according to your plan. Divide each item in a commented section of code.
  4. And finally, start coding.

You might say, that is a waste of time.

It is NOT a waste of time to plan your work ahead. It will save you time in the end and you won’t ruin someone’s day when they need to continue working on your code.

If you already have your layout, your helper classes, the elements style, do you know how easy and fast it is to create whatever you need? How organized everything will be and how easy it will be to find whatever you need without getting lost inside the code?

My advice is THINK! And whatever you do WRITE COMMENTS!

One day, you and many others will be grateful for your thinking before coding!

Don’t let the image below happen to you or anyone after you, when you have the power to prevent it.

Finally, let’s all try to live by John F. Woods’s saying:

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live!

--

--