Skip to content

Two Vital Skills to Learn Code Faster: Debugging and the Dry Run

Photo by Jair Lázaro

Learn to learn code faster, using techniques honed by years of study, neatly packaged into one book: How to Learn Code

To code requires both debugging & dry running. To become proficient at these is to become proficient at coding. It is impossible to grow as a coder without growing aptitude in both these capabilities.

They are abilities that require repetition & progressive complexity.

Your goal as a coder should always be to grow in these two abilities.

What Is Dry Running?

When you read code, you are dry running.

Photo by Blaz Photo

Dry running is the act of behaving like the compiler and imagining code running as you read it.

It is to imagine the logic of the code, holding variables in your mind and running top down through source code.

Often, many people say “my mind doesn’t work that way”, or “I can’t code myself out of a paper bag”.

The idea that the mind is static and cannot improve in imagining code is a common misconception.

The truth is, the average human cannot dry run code at the beginning of their adventure.

Dry running is an aptitude which must be improved.

There is an adaptation of the mind that happens as you code and read code.

The speed and starting point of this adaptation is different per person.

Only seek to improve yourself. Don’t look at others. Believe you can do it.

Just read your code and imagine the logic in your mind.

As you do, your mind will adapt in time. 

Photo by Wasil Ahammed

Often, dry running is the missing key that stops a coder from progressing.

They get caught up in the genius of another. Don’t do that, just focus on improving.

At first you won’t be able to run a function or loop in your imagination. Perhaps you can do 2 or 3 lines of a function or loop.

As your dry running ability improves with usage, you can eventually do 5 lines and 1 variable.

Eventually you can do 10 lines, 1 loop and 1 variable. 

Then a year later 25 lines, 2 loops, 1 function and 2 variables all in your imagination.

Heck in 5 years you can probably do 50 lines!

Photo by Max Duzij

Dry running is a cognitive facility.

Cognitive facilities improve with usage and progressive complexity.

By improving your dry running aptitude you widen your capability to imagine code.

This is an essential skill in programming. 

How do you practice dry running?

The first and foremost way to improve your dry running ability is to write and read code.

As you do so, over time your mind naturally adapts.

You can use debugging tools and print lines to assist you.

But, your goal should always be to imagine code. 

A more direct approach, and this is a good way, is to practice competitive programming.

The main purpose of competitive programming is to practice dry running.

I wrote a guide to getting good at LeetCode, in case you wanted to delve into that.

Photo by Alexander Mils

But, LeetCode or competitive programming centers around dry running. Debugging and other skills take a side line in that space.

In technical interviews and competitive contests, it is standard practice to not even execute the program until after you have dry run the code and ironed out all the logic.

The goal of solving problems on LeetCode is to know and write the solution while executing once at the end.

Now, of course you fix up syntax issues when you execute the code but the logic is supposed to exist without printing lines or using a debugger.

Code is all done first.

You are the compiler in competitive programming.

This is an excellent way to widen your ability to imagine code and many of us, me included, need this practice.

What Is Debugging?

Debugging is the core of programming. The act of debugging is the teacher of how to code.

Photo by Timothy Dykes

Debugging is finding solutions to problems. Debugging is solution seeking as well as code congruence (making the logic of the code equal to the logic of your imagination).

To imagine something and put it into a machine is done by solving 1,000 ways not to do something and 12 ways to do something and choosing the best way.

It is a mass storage of problems and solutions which you gather over the years.

Your progress and learning in debugging will drive your competency as a programmer.

How do you practice debugging?

You practice debugging by solving different technical problems over and over again, debugging.

Photo by Edge2Edge Media

The more you solve the better coder/tech person you become.

Many people avoid this. They see it as a chore or something painful.

This is what makes the difference between a programmer and a non-programmer.

A programmer loves the battle, loves debugging problems. 

They thrive on it. They know their aptitude for that technology will improve as they amass the knowledge of doing things.

Others, just want to get it over with. They want the solution, not the problem.

If you can come to love debugging and commit to it every day, your understanding/code skill as a programmer will improve.

You need this to learn programming at a higher level.

Debugging vs Dry Running

One is a cognitive facility and the other mass storage.

Photo by Fly 😀

These abilities are the keys to the kingdom. They unlock a potential hidden to those who claim, “I can’t code myself out of a paper bag”.

If dry running is to imagine code, debugging is to facilitate it.

You need to both be able to implement and imagine, in no particular order.

Through time and implementation, these improve and you can finally be an epic coder…

Anywho, I hope you learned something…

Happy coding!

Resources

Guide to LeetCode: https://jessenerio.com/how-to-get-good-at-leetcode/

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Search this blog

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Newsletter

Subscribe now to get my library of freebies + weekly emails with coding, tips for learning, and resource tips.

Learn to learn code faster, using techniques honed by years of study, neatly packaged into one book: How to Learn Code

Top content