Three good practices every programmer should always follow!

Pranav Kundaikar
Bolt IoT
Published in
5 min readJan 18, 2017

No matter what level of programmer you are, there are a few things that every programmer should follow to ensure a hassle free life (which never really happens :-P). Jokes apart, there are some practices which could help you solve trivial problems as well as improve your quality and efficiency as a programmer.

This is a must read for students and those who are just getting started with programming. Here are 3 practices that you must follow to become a better programmer:

1. Use version control systems

Very often, when we are assigned a project, we tend to execute it feature by feature. But during the development phase, there are various instances when we wish to modify parts of the code e.g. add, undo, redo, delete etc. This is not purely possible with the undo button. It so happens that a minor change can break our code completely and we need to spend hours trying to figure out what went wrong.

If you are a part of a team collaborating together to build an awesome software, there are always multiple people working on the same program. Thus it becomes very crucial to know who has made changes, what changes have been made, what was the reason for making the change, when the changes were made etc.

A version control system helps in solving the above problems, by tracking every change made in the code, as commits instead of the conventional practice of saving the entire file in other storage formats. This allows the users to have multiple versions of the same file so that they can experiment with the file in various ways and retain or discard changes based on the requirements. There are various version control systems available, with Git, SVN and Mercurial being the most popular ones. There are also various online services such as Github and Bitbucket which allows users to upload their version control folders, commonly known as ‘repositories’ on the Internet so that in the case of a system failure, none of the work is lost.

2. Code reviews

“Code review is like a pair of pants. If you work at home, pants are optional. But if you are in public, you’d better make sure you have pants on, even if no one looks at you.”

Has it ever happened to you that you have completed a coding task and felt quite pleased with the result, and then someone using your software comes back to you with a couple of bugs (or some more :P). So, why does this usually happen?

That is because during the initial development phase, there might have been some edge cases that you might not have considered or you might have introduced some bad code just to give you the expected result whose implications don’t stand out at first sight.

Code reviews are a great way of retrospection. To go through your code in depth and validate a few set of checklists such as whether the code contains any logical errors? does it really achieve the goals set during the project’s initiation phase? does it follow the general coding guidelines? etc.

Getting your code reviewed from one of your team members is a very valuable. Firstly, your team members can pin point ways of improving the implementation of a particular piece of code, some cases that might have gone unnoticed by you. Secondly, other members in your team would also know how your code works, which means you do not have to always be present to handle issues related to your code in case of some production emergency. And last but not the least, it can be a great way of learning if you are getting advice from a senior engineer, or it can help get new insights from junior engineers.

3. Test your code!

“All code is guilty, until proven innocent.” — Anonymous

Imagine a scenario where you have a perfectly working modular code, and you introduce some changes and your entire code stops working. Then you have to painstakingly insert various debug points all across the code to figure out where the bug is located. This means you are wasting precious time that was allotted to development as well as you are irritated about the fact that the code does not do what it’s supposed to.

Tests address this issue in a very beautiful way. Although writing test cases is one of the most boring tasks for a programmer, but if done properly it can save loads of time during debugging. Testing enables you to test your code in various ways. You can write unit tests to test each part of the code independently, then create integration tests to test that the code works when integrated with other parts in the system.

Testing ensures that your code meets the requirements of the project, works for all expected inputs, works in the environments for which it is designed, etc. Testing is a life saver when it comes to ensuring that your code has not been broken due to the introduction of some new code by you or teammates.

This blog is written with the purpose of introducing some best practices I follow in my day to day work. You can further explore these tools by studying about them independently. I do not claim to be the subject matter expert in this and would encourage you to go ahead and read further about ways you can improve yourself as a software developer. In the life of a programmer, importance of the tools like version control systems, code reviews and testing is so paramount that it makes them the most crucial ammunition in your “arsenal” when you are playing the “Game of Codes”!

Bolt is an Internet of Things platform that helps you quickly and easily build IoT products and projects. If you want to learn more on Internet of Things or build an IoT project, visit http://www.internetofthingsworkshop.com

--

--

Pranav Kundaikar
Bolt IoT

Cofounder & CTO at @inventrom, an Internet of Things Startup. Inventors of Bolt IoT platform.