Keep your code clean and simple

Matej
3 min readJun 16, 2020

--

Have you ever heard that saying that when you meet someone you already make up your mind about them in first couple of seconds? Well it’s pretty much the same with code. When you open up the file and get that first look it will already determine with how much enthusiasm you will work with it.

When you write code, make sure it’s simple and most of all readable. Many developers don’t realize that code readability is a very important, specially when you are starting out and your code might go in for a review.

Keep it nicely structured and don’t over engineer your code — just make it work. You can always come back later and make it better, but already covering all scenarios that might happen some day is a waste if time specially in production environment where time is money. Coming back and enhancing your code, will also make you a better developer later on and really push you to the next level.

Comment your code so it’s easier to pickup later but also don’t push it too hard with comments so the files become a mess and you have to scroll for ages to get to the crucial part. For extended explanations and notations you should keep code documentation. But while comments are nice and cool, indents in your code can really make your code look beautiful or a hot mess. Take that extra time and keep your code structured and properly indented. No one wants to look at a pile of hay. Specially for newer coders, I would recommend keeping the indents slightly bigger until you get used to it — but at the end of the day it’s personal preference, as long as you keep it nice and neat on every level. Of course you can use a code formatter and just format the code you get, but then again, do it for yourself and someone that might potentially take over after you.

Write your own clean and simple code, don’t just go to stackoverflow or any other tech site and copy a solution and paste it in. Make sure you understand what you are doing. I’ve seen many cases where there were blocks of code where some were useful but a big part of it didn’t really do anything because it was written for a similar and at the same time for a completely different scenario.

The code you write basically represents you and your attitude towards the project. Try to imagine a scenario where you have to pick it up again after a long period of time, or that you have to pick up the project after someone else. You would probably want the code to be nicely structured, clean and simple. So just do it for yourself and others, so keep your code clean and simple.

--

--

Matej
Matej

Written by Matej

Developer, Investor and digital enthusiast - oh and a meme lord!

No responses yet