Coding Tutor Tip 9 — Caveman Debugging
When I was very young, I tried to learn web programming. I think it was this book called ‘Head First’. The book was kind of different from all the other books. It had these colorful pictures which reminded me of a comic book.
I love comic books. Grew up on a heavy flow of The Phantom and Batman.
Now, yes, my historical weakness with front end development is in my genes, I suppose. That book never helped me become a front end expert. It’s my fault, not the book’s. The book is good.
However, I did learn this thing called ‘caveman debugging’. Also, don't want to leave out the ladies. You can also call it, ‘cavewoman debugging’.
So, what does caveman debugging imply? Here is a code snippet from a codepen of mine.
console.log(`The CaveMan Debugging Code Has Begun.`);function AddTwoNumberers(number1,number2)
{
console.log(`AddTwoNumberers has begun.`);
console.log(`The first number : ${number1}. The second number is ${number2}`);
let result = number1 + number2;
console.log(`The result is : ${result}`);
console.log(`AddTwoNumberers has ended.`);
}AddTwoNumberers(69,69);
And here is the output.
"The CaveMan Debugging Code Has Begun.""AddTwoNumberers has begun.""The first number : 69. The second number is 69""The result is : 138""AddTwoNumberers has ended."
So, that’s what caveman debugging does.
It’s essentially a very low level, highly time consuming and inefficient way of logging out every possible step that is happening as the program executes.
In the given example, yes, it seems like an overload. Using a nuke to fish out some rabbits. But, it is pretty cool though. As a tutor, and on my hobby projects, I constantly use caveman debugging with whatever logging facility is available in the language I am using.
Final Note
It helps me a lot. Obviously, a lot of developers don’t like it, but it has helped me immensely. You can make use of it as well, especially in your early, learning days of learning.
I work as a full time freelance coding tutor. Hire me at UpWork or Fiverr or Stack Overflow. My personal website is here. Find more of my art at Behance and Unsplash. Also, I have a Podcast. Also, I am on substack.