Codementor Events

Tips to improve your programming skills

Published Oct 15, 2017Last updated Apr 13, 2018
Tips to improve your programming skills

Spend less time debugging!

To answer a question that I’ve been hearing often, I will show you 4 tips that I personally use to spend less time on debugging!

Don’t feel like reading? Watch the video version👇

Tips to improve your programming skills Part 1 - video


Tip #1: Isolate problems

Programming is about solving problems. And when these problems get complicated, we just don’t know how to make it work anymore. We get stuck!

This is especially true when you’re working on front-end code. Things seem to be impossible when you’re nested into multiple divs, in a partial view and you’re also using a templating engine.

So whenever you get stuck, just create a new codepen or an empty HTML file in your project that loads the same libraries and try to write your solution there. This will eliminate distractions and external factors and lets you focus on solving this particular problem.
Once you’ve got it working, take the solution and carefully place it back into its correct location.


Sample codepen

This also applies when writing programming code, once you breakdown a problem into a series of transformations , you can isolate a specific problem and work on it independently from the noise.

Tip #2: Use GitHub for debugging

You’re stuck on an issue, and the error message clearly states that the error is beyond your control. You can’t find anything on Google either.

Well actually, most of the software you’re using is open sourced on Github.
And when people encounter bugs with that software, they create a new issue on that repository’s Github issues.

So next time you’re stuck, find that software’s GitHub repository and browse their issues page. You’ll find tons of relevant issues that are either solved or in progress.


Use Github issues for debugging

Tip #3: Write tests for your code

A great way to write better code with less bugs is to start by writing tests for your code.
You might not have a good test coverage but you will be forced to improve the quality of your code. That’s because it allows you to think through your implementation when writing the tests, before you write the actual code.
You will also be able to easily refactor your code while making sure that it doesn’t break.

Let’s take a simple example.

Let’s say you’re working on a user registration functionality, when you rush to implement it, you might forget about validating your data or sending a welcome email.

When you write the tests however, you will have to think about the end result. So you will need to write tests to cover both success and error scenarios.


Registration Test case

After you start writing tests, you will check for a successful entry in the database for that username and password, you will also check that a welcome email has been dispatched.
If you do this for every single function you write, you will progressively improve the quality of your code.

Tip #4: Read the source

Whenever you’re working with frameworks, you’re working at a high level.

So setup a hotkey (mine is CMD + G) that takes you to the original function definition, and every time you use a method defined by a framework you’re using (for example Laravel, VueJS, Rails, Angular, etc.) hit that hotkey and read the source code for that framework function.

You will be surprised how much knowledge you can amass once you incorporate this tiny habit.


Source code for Request::input from Laravel Framework

The code you’ll be reading may not make sense in the beginning, but overtime you will learn a lot by reading other people’s code. Not to mention that you will occasionally discover that this function that you’ve been using for too long, had an optional parameter that makes your life much easier.Stay tuned for more!

I hope you enjoyed these tips. This was Part 1. Stay tuned for Part 2 and more upcoming articles.

Make sure to subscribe to my YouTube channel using this magic link

Discover and read more posts from Jad Joubran
get started
post commentsBe the first to share your opinion
Show more replies