Three practices that will make you a more efficient programmer

TL;DR Write a developer journal, automate repeating tasks with scripts and share your journal and scripts with your team.

I would like to share 3 simple, concrete and non-revolutionary practices I have been using at work as a developer, which I feel make me more efficient, and generally makes my work less frustrating — and I believe every programmer could benefit from.

#1 Write a developer journal

TL;DR Use a simple markdown file and manage it in GitHub

As developers we spend a lot of time trying to solve small and very specific problems. For many, including me, the go to place is StackOverflow. You brainstorm with yourself iteratively for just the right search phrase, open a few too many tabs, and finally find the solution which works for you. Sometimes you find something that nearly works, and you spend some more time to customize it to perfectly fit your needs.

And then what? How many times have you gone through this process only to face the exact or very similar problem a few months later? Now you have to waste time to find a solution for a problem which you already solved — and it becomes even more frustrating if you know the solution is out there, but since you can’t remember how exactly you searched for it in the past, you can’t even find it anymore!

The same goes for non-googleable problems, like ones related directly to the product you are working on. How did you solve that bug the last time you’ve seen it? What is the location of that file you need to edit to change that thing in your system? You probably had to ask someone from your team for a a solution, and now you have to bug them again.

It took me more than once or twice for these things to happen before I realized I have to document the way I solve this kind of problems, and then it took some more time to find the right way for me to manage this documentation.

I have found that what works for me is managing a single markdown file which I host in GitHub. That’s it. The entries are short and use a repeating pattern to keep me concentrated on actually documenting the problem and its solution. Here’s an example of an actual entry from my journal:

I use the same pattern for every entry:

  • Problem — describe what you are trying to achieve
  • Suggested solution — how can the problem be solved? If there is more than one possible solution, document it as well — sometimes documenting how not to do things is also valuable
  • Tags — keywords related to the problem to make the entry more searchable

Here is a my entire journal if you would like to see more entries.

And here are some answers to questions that may arise:

  • Why markdown? It’s very easy to learn and use, plays well with code examples, provides in-file bookmarks and can be written in any text editor.
  • Why confine to a repeating pattern of problem/solution/tags? Keeps you focused and provides an option for future further organizing
  • Why GitHub? Displays formatted markdown, provides backup, accessible anywhere and allows privacy if you want it

#2 Automate repeating tasks with scripts

TL;DR When you find yourself doing the same thing more than 3 times you should probably write a script to do it for you.

Sometimes laziness is a virtue — you’ve probably ran into this quote by Larry Wall, the author of Perl:

Laziness: The quality that makes you go to great effort to reduce overall energy expenditure…

During a day of work, we perform many small tasks. Let’s say I’m working on a software that has user management. There is a bug in the backend related to user creation, and I need to create a new user multiple times, to view the logs, to see if I fixed the problem and what not. I use the UI, fill all the fields in the form (which are not few — name, password, company, phone, e-mail…) each time from the beginning. And it’s annoying. It could be made easier. After all, I’m not fixing the UI, it’s not part of the problem, then why do I have to interact with it so much?

It turns out that it is quie easy to automate interactions with UIs (assuming it’s web based, like most UIs today) — all you have to do is create a script with curl, and luckily it’s really simple. Just press F12 to open the dev tools (if you’re using chrome), fill the form (create user to continue with the example) and press Save or Create or whatever it may be.

Then, under the network tab, to the left, you will see the request made to the backend. Right click it, choose Copy and and press Copy as cURL (bash):

Paste it in a file, and voila, you have a script to create a user! You may have to make slight modifications here and there, but overall this is a very quick method to create a simple script to automate a mundane, repetitive task. If you want to take it to the next level, you can use this nice tool that converts curl commands to python requests, for cases where heavier lifting is required.

It’s not only about saving time (although that’s a nice bonus) — it’s about being able to focus on what you actually want to do.

Of course, it is a great idea to save these scripts in a repository in your team’s VCS.

#3 Share with your team

After a while practicing writing a journal and automating stuff you will find yourself with documentation for important flows and somewhat of a cook book for you product. You have made your life easier — now share it with your team and make their lives easier!

This type of documentations could help onboarding a new team member, and more experienced team member will find the mistakes you made or give you advice on how to make things even simpler.