Callbacks, Promises, and Async/Await in JavaScript

Image for post
Image for post
Photo by Álvaro Bernal on Unsplash

JavaScript is single-threaded, which means that only one thing can happen at a time. Synchronous code is executed from top to bottom in the order that the code is written. Synchronous code is also “blocking” — each line of code waits for the previous line of code to be executed before it runs.

In contrast, asynchronous code is “non-blocking” code that allows long-running requests to not block the main JavaScript thread. When the request is finished, additional code can then be executed. This is generally done in one of three ways:

  1. Callbacks
  2. Promises
  3. Async/await

Let’s look at a few examples to see how we can write asynchronous code using these three approaches. …

Image for post
Image for post
Photo by Michael Dziedzic on Unsplash

I still run an EC2 instance on AWS that I configured years ago to host some of my side projects. It’s using a Linux AMI (Amazon machine image) that is woefully out of date and also wonderfully under-performant when traffic on my site is heavy.

Recently my EBS (elastic block store) volume that I have attached to my EC2 instance became full. …

Image for post
Image for post
Image courtesy of DocRaptor

Web apps that contain tables, charts, and graphs often include an option to export the data as a PDF. Have you ever wondered, as a user, what’s going on under the hood when you click that button?

And as a developer, how do you get the PDF output to look professional? Most free PDF exporters online essentially just convert the HTML content into a PDF without doing any extra formatting, which can make the data hard to read. What if you could also add things like page headers and footers, page numbers, or repeating table column headers? …

The importance of merge request templates

Photo by Glenn Carstens-Peters on Unsplash.

Filling out a checklist is often thought of as a mind-numbing, rote task. But what if I told you that checklists are actually essential to getting the job done right?

Checklists have been proven to help reduce human errors in complex tasks, such as flying airplanes or performing surgery (see The Checklist Manifesto by Atul Gawande).

So why not apply checklists to software engineering? In this article, we’ll examine the benefits of using merge request (or pull request) templates prior to merging new code.

Merge Request Templates

Most software companies use Git in conjunction with platforms like GitHub or GitLab to provide version control for their code. …

Image for post
Image for post
Photo by Tim Gouw on Unsplash

I write code for a living. You might say I’m a professional software engineer, but really software engineering is much more than just a profession — it’s a lifestyle. The hoodies, the ping pong, the endless snacks and soda… it’s all true. And yet, as rewarding as this field can be, I have a confession to make: Sometimes I wish I never learned to code.


Ever since I started learning to code, browsing the web has never been the same. No longer can I simply accept the errors I encounter on other sites as I use them. …

Learn how to learn

Image for post
Image for post
Photo by Aaron Burden on Unsplash

The web is filled with self-help articles showcasing titles like “How to become a senior software engineer” or “Top 10 technologies you must know in 2020”. There are literally thousands of them.

While many of these articles contain helpful advice, I believe all of them can be distilled into a single lesson:

The single most important thing you can learn as a software engineer is to learn how to learn.


Image for post
Image for post
Photo by Josh Riemer on Unsplash

Learning how to learn is a meta-skill, which means it’s an ability that will enable you to grow in more than just one area. To name a few examples:

Learning React is a skill. Learning how to quickly pick up new UI frameworks and libraries is a meta-skill. …

Advice and lessons learned from Laszlo Bock’s book, “Work Rules!”

Three women at a meeting
Three women at a meeting
Photo by Christina @ on Unsplash.

Google is well-known for hiring only the best of the best. They’re incredibly selective, hiring only 0.25% of candidates who apply, making it harder to get a job at Google than it is to get into Harvard University (source: Work Rules!, page 69).

In his book Work Rules!, Laszlo Bock (Senior Vice President of People Operations at Google from 2006 to 2016) explains why Google’s hiring process is so rigorous. It’s more effective to spend time hiring the right people than it is to hire average performers and then try to train them to be top performers (Work Rules!, …

You can learn a lot about someone’s proficiency by asking the right questions

Woman writing on a whiteboard.
Woman writing on a whiteboard.
Photo by ThisisEngineering RAEng on Unsplash.

When interviewing for a software engineering job, it’s common to be handed a dry erase marker and told to solve some arbitrary problem:

  • “Write a function that determines if the letters in a given string can be rearranged to form a palindrome.”
  • “Implement a memoization function.”
  • “How would you sort an array containing up to 100,000 randomly generated integers?”

As an interviewee, I used to hate whiteboard problems. The pressure of having to understand and solve a seemingly pointless or obscure problem in front of a stranger is enough to give anyone anxiety. …

Exports and module factories and mock implementations — oh my!

Image for post
Image for post
Jest logo

When testing JavaScript code using Jest, sometimes you may find yourself needing to mock a module. Whether it’s because the module or the functions it exports are irrelevant to the specific test, or because you need to stop something like an API request from trying to access an external resource, mocking is incredibly useful. There are, however, several different approaches to module mocking in Jest, which can lead to confusion. Which approach is the right one for any given scenario?

In this article, we’ll walk through various scenarios using ES6 modules with named exports, a default export, or a mix of both. …

Web development made easy with a hosted GraphQL backend

Pokémon Pokédex app
Pokémon Pokédex app
Pokémon Pokédex app

Frontend developers want interacting with the backend of their web application to be as painless as possible. Requesting data from the database or making updates to records stored in the database should be simple so that frontend developers can focus on what they do best: creating beautiful and intuitive user interfaces.

GraphQL makes working with databases easy. Rather than relying on backend developers to create specific API endpoints that return pre-selected data fields when querying the database, frontend developers can make simple requests to the backend and retrieve the exact data that they need — no more, no less. …


Tyler Hawkins

Senior software engineer. Continuous learner. Educator.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store