About Code: Keeping it Clear and Clean

I’ve been too design driven on all of my posts and I’ve forgotten about a very important part of my career: coding. That is currently one of my main tasks, and I wanted to talk about what I’ve found out to be a very common issue among developers: understanding somebody else’s code.

It is such a headache to understand someone else’s coding logic! I won’t mention specific companies, but I’ve been to many places where they have no standards at all, or they have them but nobody ever uses them. I venture saying that most of the people there don’t even know they have standards.

And what are these so called standards?

There are a lot of tiny considerations you can follow in order to make your code understandable for the next poor person who has to deal with it. It won’t make your life more difficult to do so, either. You just have to get used to having them in mind while you are working.

Here I bring you the main ones I’ve identified. There might be more, but I believe these one will cover the essentials.

    1. Use the correct indentations – You know what I mean by this, right? I believe the image explains a lot better. The one on the right side looks a lot different than the one on the left side. The one on the left side can make our lives a living hell (I usually have to spend some time correcting indentations to actually know what I’m supposed to do next).
  1. Write comments when needed – Don’t flood your code with comments, that’s not necessary at all. Just the main functionalities, or parts you consider confusing. That goes a long way.
  2. If you do comment, write MEANINGFUL comments – Don’t write stuff like ‘This is the one that does a lot of stuff!’ because you are better off not writing anything…
  3. Use standards for naming variables and functions - The names you use should have some sense to them, and not something like temptemp (happens a lot…).

Any others I missed? I’ve found these ones to be really useful. Let me know what you think!