Conceptual overview of Jest Enzyme testing

jest and enzyme testing blog post banner nickang

I recently had the privilege of introducing frontend testing to our code base at work. With 5 engineers working on different parts of the product at any given time, it finally made sense to add automated tests. I can foresee this helping us cut down time spent on debugging and improving the overall quality of the product.

Because our frontend stack was React and Backbone, we needed a test library that can test React components. Some deliberation later, we decided to go with Jest (by Facebook and used internally at Facebook) and Enzyme (by Airbnb and also used internally at Airbnb).

Continue reading “Conceptual overview of Jest Enzyme testing”

Temptation to just build stuff

mannequin wearing santa hat looking broken
Photo by Buzz Andersen on Unsplash

I’m beginning to adopt an engineer’s mentality of wanting to build things because it’s fun and I’d probably learn a few things along the way.

For example, I’d recently wanted to build 2 Chrome extensions with very specific uses.

Continue reading “Temptation to just build stuff”

Remember why you are programming

spectacles sitting in front of a laptop focusing text on screen - remember why you are programming blog post banner
Photo by Kevin on Unsplash

As a programmer, you probably get a little carried away once in a while. You know, getting engrossed in the sophistication of another developer’s implementation, be it beautiful or ugly (or both) and having an engaging conversation with your colleague about it. Yeah, I can tell you know what I’m talking about!

But I recently realised that that can sometimes happen at the expense of good user-centric development.

Continue reading “Remember why you are programming”

Implementing a Queue in JavaScript?

Yesterday I asked myself whether it was necessary to implement a stack abstract data type in JavaScript. The answer turned out to be “no,” because you can just use the built-in Array data type to simulate a stack without obvious performance penalties.

Naturally, I started asking myself, what about a queue? Should we be implementing a queue in JavaScript?

Continue reading “Implementing a Queue in JavaScript?”

How to prevent jQuery from loading image in parseHTML

This post is inspired by a recent bug fix at work related to jQuery’s parseHTML() method.

I noticed multiple redundant calls to our server endpoint each time a user saves an email template using the drag-and-drop email builder of Metisa.

The bug, when traced to its end, was nothing like what I’d originally suspected. Because we use Backbone.js for the front-end model layer (to make API calls) with React.js as the front-end view layer, I had initially thought it was Backbone making redundant API calls.

Continue reading “How to prevent jQuery from loading image in parseHTML”

What is DRY (in programming)?

what is dry blog banner nickang showing weed growing on white wall
Photo by Ben Neale on Unsplash

Ever heard someone tell you that your code is not “DRY”? What’s the deal with that? Are they saying that your code can hold a lot of water…?

Sorry for the bad joke. DRY is an acronym, and it stands for Do not Repeat Yourself. As far as I can tell so far in my short career as a software engineer, this is one of the most revered principles in writing software.

In this post, we’ll explore why it’s important to keep your code DRY and in general, how you can go about doing it.

Continue reading “What is DRY (in programming)?”

Why use Binary Search Tree?

why use binary search tree banner with peace hand sign
Photo by Nathan Fertig on Unsplash

If you already know what a binary search tree is for and how it works, read on to learn about their main strengths and weaknesses in this post! Otherwise, feel free to take a moment to read part 1 for an introduction.

Why is a binary search tree useful? What are some of its main weaknesses?

Let’s try and answer those questions in this post.

Continue reading “Why use Binary Search Tree?”