Program Efficiently, Not Carelessly

6 tips for refining your efficiency as a programmer

Aryaman Kukal
The Startup
5 min readJun 14, 2020

--

1. Writing Pseudocode

visual credit

You might be an experienced programmer, but you can probably admit you don’t do this.

Now you may ask: “What exactly is pseudocode?” Pseudocode is basically a plan for what you’ll work on in your program. It’s a tentative blueprint that explains every step you need to take in reaching some goal. Pseudocode should, in my opinion, always be written with plain English. I’ve seen people writing pseudocode that is practically nothing but actual code. That might work for some people, but it can get very confusing very fast.

Pseudocode lets you solve your problem with pre-written steps, which, first of all, makes the workload as well as the overall complexity look a lot less, and second, saves you time because you can now prioritize certain parts, and leave some to work on another time.

2. Writing More Comments

visual credit

People either do this to a very little extent or not at all. This goes hand in hand with writing pseudocode. While pseudocode is the general blueprint for the big steps in the program, comments are the brief, in-depth explanations behind the individual lines of code.

Putting this as simply ask possible. If you want to understand what you did, and not have to remember every step, then you’ll have to take a little extra time to explain why you wrote that line of code. Why you created this class. Why you have to use this function to fix that. How and why this is so important. You have to ask yourself these questions and answer them in the form of comments alongside your code.

This what programming is all about. Being able to write meaningful code that you can go back to, comprehend, and explain to yourself as well as others.

“Programs must be written for people to read, and only incidentally for machines to execute.”

— Harold Abelson

3. Debugging

Do you remember that tiny bug icon at the top corner of your shell? If not, you’re just like thousands of other programmers, including me only a few months ago, who are missing out on a breakthrough that has been around for longer than you can remember.

visual credit

Debugging. It is just a term that describes scouring code and fixing bugs, or errors, from your code. However, we don’t have to do this while relying on only our human intellect. The debug button in your shell allows you to run your program interactively while watching each and every variable and each and every part of your source code changing as the program carries out. You’re essentially telling a computer to explain to you their thinking and reasoning behind the output it provided.

Anytime you’re dealing with an error and you have absolutely no idea why or how that error came up, the solution is debugging, specifically the debugging feature. You can see exactly what line your program went wrong in, and you can fix those errors much faster.

4. Run, Run, Run!

visual credit

A grave mistake programmers make is when they write huge amounts of code under the impression that the code will execute smoothly when they get to running it. If you do this, you’re only making things harder for yourself.

The more you test something, the less prone that something is to errors, which leads to a higher overall efficiency rate. Run your program after every step. If you created a function, call the function and see if it actually works.

Don’t wait till it’s too late to test your program. Don’t wait to the point where the program starts to confuse its creator. This will help you in the long run, when a usual program will exceed the thousand line mark.

5. Doing Frequent Exercises/Challenges

visual credit

I can’t stress this enough. Doing short exercises here and there is key for refining your programming knowledge. These exercises give you chances to apply past-learned concepts to complex logic-based situations or even discover gaps in your knowledge that should be covered up.

For some free and addictive programming challenges, I recommend looking into Edabit. It has over 10,000 interactive programming challenges available in 8 languages: Python, Java, JavaScript, Ruby, Swift, PHP, C++, and C#. It’s a great website for all ages and backgrounds. I highly recommend you sign up.

6. Taking Breaks

visual credit

This seems pretty intuitive. Unfortunately, many people ignore it. It’s simple. Take breaks. We all know how hard it is to leave your screen while in deep thought, but think about it like this. What’s more important: you’re sanity, or getting something done? Go outside. Get some air. Take a short walk. Direct your attention to something else; something less important. Don’t tire yourself too much. You won’t work efficiently if you’re stressed, frustrated, tired, or anxious. You would just be hurting yourself.

When you have gained some peace, put a smile on your face, and get back to work.

“I’m not a great programmer; I’m just a good programmer with great habits.”

— Kent Beck

I hope this helped you realize something. Stay safe everyone.

--

--

Aryaman Kukal
The Startup

tech enthusiast ~ programmer ~ avid writer ~ always curious; rarely express it ~ freshman @ American High ~ “Make it work, make it right, make it fast.”