Whether you are working for a big software company or a small sized startup, writing good code is pretty much critical to your success. But the catch is it is not very easy to achieve without proper motivation from your side.
I have been coding professionally for almost 4 years now. First two years were as a freelancer and I mostly followed Get Things Done mode during that time. It was okay then because it was mostly a one time gig and once done you didn’t had to do anything with it. Though I never wrote really bad code even at that time but the amount of maturity and knowledge required to write code that is maintainable, DRY and has some documentation was clearly not there.
While I joined my first company back in 2013, I really struggled against my bad habits. I was able to solve tough technical problems as problem solving is always close to my heart but there were serious issues with my code quality. Sometimes there was some indentation issue and something there were some code repetition. I was lucky to have my Mentor “Ruben” to closely look at my code and review it sharply and give his most honest feedback. Upon pondering about the review I realized most of the issues were coming because a certain amount of thinking and carefulness that was missing from my workflow. I didn’t had my editor configured properly. Mix of tabs and spaces will obviously come back to bite you and code will look ugly on browser even though it looked fine on your editor. (Sublime Text, I am looking at you).
Now, after almost an year later I am a improved and mature programmer than what I was at this point of time last year. So what changed?
Here is a short summary of things I did in order to get better at writing code:
- I started reading classic books on programming. Understanding programming and computer science is pretty much vital to your growth as a software developer. Dreaming about making big in this field without having solid basics is a fools errand.
- Read a lot of good code. Discuss about it, blog about it and finally incorporate those into your own code. This is pretty much most important to improve the code you are writing. I started reading a lot of good code, on an average of 1 hour daily. With loads of Open Source projects available on Github and bitbucket it is pretty easy to do so.
- Follow strict mode in almost every language your code on. Use Pep-8, JSHINT, CSSLint, Grunt. This might be painful at beginning but it would cover a lot of ground that you might not know as you are not an experienced developer.
- Learn and use Travis CI and Jenkins system that would automate a lot of these things in your code.
- Write a lot of code and open source it. Also, contribute to a good number of OSS projects. I have done a lot of this in the past year and believe me it has really helped in improving.
Read the f**king documentation - This is kind of most important if you want to really use the power the language or the framework provides. Otherwise, you will keep writing shitty code because you were never aware better way exists.
- Use version control- Version control gives you an opportunity to look at your code before committing. Use this powerful feature. Always review your code before your commit. Always review a pull request and merge.