lurb3
Posted on March 10, 2020
I've started writing code on a daily basis 4 months ago and I am struggling to get a clean flow of thinking and writing code.
In order to write better code I need to think of a problem's solution before actually writing it. That solution should be very clear in my mind so that I don't struggle when I am coding.
This should be my first step: think about the problem and achieve a possible solution.
The next step is to write the code. My code needs to follow the solution's "guideline" that I've come up with and should be as clear as possible. With this I mean the naming of the variables, functions, classes, etc. The flow of the code should represent that solution's thought process.
The next step should be to have clean code. Seperate code actions from general code. I should make functions to do a specific thing instead of doing a lot of things. It's better to have two or three extra functions than one function that has too many functionalities.
I should also use native code to simplify the reading: for example, use map function whenever possible instead of complex for loops, use array pop function instead of writing a function my own.
Finally, after all of this work, the code should be reviewed either by me or another person because I tend to be a little bit confusing, usually write more code than I need and there's also the need to catch any possible bugs.
Photo by Oliver Hale on Unsplash
Posted on March 10, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
October 29, 2024