For anyone without a technical background, there’s a feeling of magic the first time you write code that makes a computer do something. Within a few days of any introductory programming course, you get a peek behind the curtains of the endless possibilities of what a human can tell a computer to do.
While most intro courses focus on the language–variables, loops, conditionals, objects and classes, etc–soon enough you’ll find that there’s a part of programming that’s separate from the language itself. This includes the tools, strategies and workflows that help you write good code, and actually construct and deploy useful programs.
While there are upsides of learning how to program in a self-guided way, it can be hard to know which fundamentals you’ll really want to learn and internalize early on. The real problem is you don’t know what questions to ask.
Here are a handful of things I’ve learned along my journey, and wish I had learned much earlier. Some of them are simple, but I think all will make you a better, more productive programmer.
Note: since I primarily code in Python, I mention a few Python-specific tools, but the principles can be applied to any language.
1. Before you write the code, write the logic
Programming is an effort in logic, not typing. It’s our job to translate that logic into a language a machine can interpret.
The beauty of a language like Python is that you can write useful programs very quickly. This is also its curse, as it’s tempting and easy to immediately start writing code without fully knowing what you’re trying to accomplish. Resist the urge.
Get familiar with pseudo-code. Write out what the inputs to your program are, what your program should do, in what order, and what the output should be. Think about what can go wrong–why won’t the data be what you think it will be? What conditions would prevent your program from running? Every time I spend more time than I think is necessary on the logic of a program, it benefits me.
2. Master your text editor
The goal of any tool is to provide leverage for you. An axe makes felling a tree easier, and a text editor should make writing and running code, faster, easier, and less error-prone. Learn and customize keyboard shortcuts, master the core functionality and make it visually appealing. Try a few before fully committing to one. Your text editor needs to be a force multiplier, not a source of anxiety every time you open it. Take a few hours to understand how an editor can make your life easier.
FWIW, after trying a few out, I use and love VS Code.
3. Get familiar with industry-standard libraries and packages
New, exciting libraries, packages, and projects arise all the time, and it’s easy to get excited about all of them. While always keeping an eye on what’s new, mastery of the core, fundamental packages and libraries that are time-tested will serve you well.
Packages and libraries become popular because they solve common problems–ones you’re likely to encounter.
You’ll also benefit from community help. The more obscure of a tool or package you’re using, the less help you’ll be able to find online.
In Python, depending on what type of work you’re doing, some core libraries to master include os, numpy, pandas, and requests (among many others). Learning these inside-out will make your life a lot easier, and give you the tools to solve the problems you come across most often.
4. Build systems, shortcuts, and scripts for the things you do all the time
This is all about quality of life, and reducing cognitive load from the things that shouldn’t require it. The cost of the task that takes 30 seconds every day, or 3 minutes once a week, is more than just the time required. It’s also the mild annoyance that comes with spending time on something you know a computer can do, and it’s just another thing we need to hold in memory.
Do your programs often have the same set-up? Create a custom keybinding that auto-populates this structure.
Do you run a script at the same time every day? Schedule it.
Do some excel manipulation, then email that out? Automate it.
There’s a very real satisfaction when you outsource a repetitive task to a computer.
5. Read professional code
If you want to be a better writer, you should read. This is also true if you want to be a better programmer. Luckily, the internet is overflowing with open-source projects that you can learn from.
Reading “professional” code has done a few things for me: first, it’s taught me how to write better code (what’s an appropriate level of extraction? what’s the best way to check for exceptions, etc.); probably more importantly, it’s built my confidence by realizing that all the basics–variables, loops, conditionals, functions–are also the things that professional programmers use. There’s a nice feeling when you see that a function is written the same way you would write it.
Flask and Requests are two, oft-cited as particularly well-written, Python libraries.
6. Use a formatter
This is the easiest step on the list and will take 5 minutes. Using a formatter will ensure the style is consistent across all of your Python files. No more weird spacing, inconsistent quotation marks, etc. You shouldn’t spend any mental cycles on how to format your code–this is a nice piece of software that takes care of it for you, and in the process, makes your code easier to read.
I use black and love it.
7. Use git
This was the most intimidating for me on the list, but git has become one of my favorite pieces of technology. At some point you’ll run into the following scenario: you’ll have working code, you’ll make an update which breaks your code, and you won’t be sure how to get back to the code that actually worked. You’ll stumble through a Project V2, then Project V3, and Project Final, only to forget which version contained that one feature you want. Git eliminates this whole process, and provides a traceable history of your projects.
Working off branches instead of a single master file makes coding more reliable, and less stressful. And if you ever collaborate with others on a program, this is likely the way you’ll do it.
I recommend starting with GitHub desktop, which makes branches, commits and pull requests a breeze, without needing to use the command line.
8. Use spaced repetition for the things you know you’ll rely on again and again
There’s a mountain of evidence on the effectiveness of spaced repetition for memory consolidation. The theory is that we should test our knowledge of something at the moment we’re about to forget it. Tools like Anki make spaced repetition easy to set-up.
While nearly everything is google-able, coding is a lot more enjoyable when commands, methods, libraries, etc are in your head, and you can stay off of Stack Overflow.
When you learn something new, create a new Anki card, go through them a few times a week, and be amazed at how much you retain.
9. Conduct an After Action Report when you’ve finished your project
Once you’re finished with a project, it’s easy to move right on to what’s next. An After Action Report helps you consolidate your learnings, and reevaluate how you went about solving the problem.
Could you have structured your program in another way? Does part of the code run slower than you would have anticipated? Did you find some quirk about your data? This exercise will make you a better programmer. It will help you think more critically about your code, and even lead you to novel solutions.
—
Nothing replaces clear thought, a well-structured program, and legible code. But there’s more to the craft of programming than the code itself, and hopefully this list helps you consider a few ways to up your effectiveness as a programmer.