Dependency Injection in JavaScript blog header image

Dependency Injection in JavaScript

In building a house, after the architecture of the house has been drawn and accepted, everything built must fit the drawn architecture. A major change along the way may result in a complete tear-down and rebuild from scratch process. Once the building has been built with cement, it cannot be changed to wood. Building physical structures is a rigid process. Building software is different. Software, unlike physical structures, is expected to be flexible....

February 22, 2023 · 5 min · Orim Dominic Adah

How to Handle MongoDB Transactions on your Local Server in Node.js

Until version 4, MongoDB lacked the ability to carry out ACID transactions. ACID transactions enable database operations (creating, reading, updating and deleting data) to be more resilient and dependable. This is necessary, especially in finance-related applications that have to do with transferring money among users. This guide is for you if you use Node.js and MongoDB. It is expected that you have installed MongoDB already and you have a running MongoDB server on your local computer....

February 16, 2023 · 4 min · Orim Dominic Adah
Design JavaScript code with tests in mind

My First Open Source Contribution to Remotion

What is Remotion? Remotion is an open source video-making program built with React. Remotion enables users to create MP4 videos using React. At the time of writing this blog post, the project is recorded to have been used by over 800 developers on GitHub and it has over 15,000 stars. Remotion has been used to make product demos, tutorials and clips for conference talks. Remember the popular yearly GitHub unwrapped videos that show an animated display of developers’ GitHub history for the year?...

February 11, 2023 · 4 min · Orim Dominic Adah
Iterator Design Pattern

The Iterator Design Pattern in JavaScript

Design Patterns In the field of programming, there exists a concept called ‘design patterns’. Design patterns are established solutions to recurring challenges in the field of software design. A sample challenge that requires the use of a pattern is that of an API endpoint that returns a list of items. It may be fine for the endpoint to always return all the items that the database has for every API call to the endpoint, but it gets to a point where the list of items to return would be unnecessarily large or some of the items in the list returned may not be needed by the client making a request to the API....

February 3, 2023 · 7 min · Orim Dominic Adah
on becoming a Senior Engineer

On Becoming a Senior Engineer

Recently, I was promoted to the level of senior backend engineer. As much as I felt that this was a stamp of recognition on the work that I had done, I felt like an impostor when I compared myself with what is out there. I have been writing code professionally for about 2 years and I have been working remotely at this company for 7 months (probation period included.) Senior engineers usually have 5 years and above of professional experience under their belt....

January 15, 2023 · 5 min · Orim Dominic Adah
setTimeout JavaScript

How does setTimeout Work with the JavaScript Engine?

If one wants a function to be executed just after a period of time T in JavaScript, what do they do? They dump it in a setTimeout and surely, just immediately after T has elapsed, the function will be run. Right? Can you predict what happens when the code below is run? You should try it out in a Node.js REPL or the console. const extractTime = (date) => date.toTimeString().split(" ")[0]; var start = new Date(); console....

January 4, 2023 · 3 min · Orim Dominic Adah
Callback Function JavaScript

What is a Callback Function in JavaScript

You know how you ask someone to call you back in a phone conversation? That’s what callback functions are. They are functions to be called later; after something has happened. In order to grasp this in practice, one needs to understand two things that there is a difference between a function name fn and a function call fn(), that functions can be passed into functions as arguments, the same way that numbers, strings and arrays are passed into functions as arguments The difference between a function name and a function call Let’s consider the code snippet below...

August 7, 2022 · 5 min · Orim Dominic Adah
NestJS Integration Testing with TypeORM and MongoDB

Write Integration Tests with NestJS, TypeORM and MongoDB

NestJS projects that use TypeORM with MongoDB are rare. The recommended ODM1 to use with MongoDB is Mongoose, but the choice is not always within our control. This article is a guide for writing integration tests in a NestJS project that uses TypeORM with MongoDB. Integration tests verify that all units required to accomplish a particular goal work together as expected. For integration tests in a backend application, database calls are not mocked....

April 7, 2022 · 5 min · Orim Dominic Adah
Asynchronous function javascript

What Is an Asynchronous Function in JavaScript?

When you look at any of the hands of a ticking clock, you will find out that it moves sequentially. It points at 1 before it points at 2, and then it points at 3 and it continues. It does not point at 4 and then 1 and then 9, in a random manner. It follows a sequence. Imagine that the hand is the JavaScript runtime and each number is a function....

March 25, 2022 · 4 min · Orim Dominic Adah
Implement JavaScript's setInterval using setTimeout

Implement JavaScript's setInterval using setTimeout

I was in a job interview pair programming session where I was asked to implement JavaScript’s setInterval method without using setInterval itself. I did poorly at that interview for many reasons, including not knowing how to implement this. The Question Implement the setInterval function in such a way that executing new SetInterval.prototype.start will start the function passed to it and run the function at intervals interval milliseconds until the SetInterval.prototype.clear method is called....

June 23, 2021 · 3 min · Orim Dominic Adah