DEV Community


How to be a better programmer?

ishaanbedi profile image Ishaan Bedi ・3 min read

1 Think Before Acting

Got an idea to develop something or thinking of adding a new feature to your existing project? Don't directly jump on your PC and start coding...

Instead take a pen and paper and note down what all you want your code to do. Think about exceptions and how you'd be handling them. Directly jumping upon coding won't allow you to think about how things should flow. Try to draw a flowchart and divide the steps into small milestones. Make sure your each and every milestone is achieved completely and no error/exception or any other problem that would compromise the whole purpose of your project is left. Being organized is the key to a successful project and will help you stay calm throughout your journey with the section.

2 Use comments, please!

This might seem obvious but most of the programmers do not use comments or use very few of them in their projects , which leads to difficult approach of understanding the algorithms and concepts involved in the project while revising/reviewing code. Make sure your code is neat and clean & well organized that even a non programmer is able to understand what your program is trying to do, with the combinations of code and the text as comments. Also having structured and highlighted comments after every section or a function or a class, etc. helps in easy presentation of your code in front of any other developer, your boss, a client or your dog...

3 Test your code again and again!

Once you feel you've completed your project or a milestone (discussed above) is achieved, try executing the program and check wether everything is running the way you want or not. The steps that your project's execution shows should match with the flowchart's steps that you created before writing the code. Try to put your weirdest thoughts as inputs (if any) to check if the program is not terminating abnormally or going out of the steps as per your flowchart or any other error is raised. Fix the error, if any arises and again execute the code following the same pattern.

4 Leave Coding For A Few Minutes

This might sound weird like here we were to learn some productive tips about coding, but now it says to leave coding. Hold on!

Whenever you're feeling stressed out, feeling stress/glare on your eyes, feeling sleepy or you're frustrated as the code is not working the way you want it to be, relax, just leave your place and engage your mind in some other activity. This might include going for a walk, taking a nap, taking deep breaths and meditating, listening some music, eating some cookies at 1:00 am, or just thinking of some random thoughts to divert your mind. Make sure you are not thinking about the problem of your code or anything related to it. Just feel that this break is a reward for your hard-work that you have done in the last session.

So that's all for this post. Hope you got to learn something new and fresh. Wishing you all the best for your next coding session.

Will catch you again in some another article. Till then, keep hustling and never stop chasing your dreams.

Discussion (0)

Editor guide