Advanced usage of TypeScript Generics

In a static-typed language like TypeScript, generics are a way to improve code reusability by introducing a controlled degree of type leniency. In this short article let’s have a deep dive into generics in Typescript and how we could use it to write lesser code and improve the general maintainability of our projects.


A simple way to think about generics is to treat them like a placeholder for type.

For instance, let’s assume a function that is used to add reviews to an entity in our made-up e-commerce platform. …

A Static Page ( Darth Vader CSS from:

In this beginner-friendly, short and hands-on article, let’s look at how we could easily set up a continuous deployment pipeline to build and deploy our static site to gh-pages, using Github Actions.

Step 1. Create a folder & Initialize package.json and git

We could use the mkdir command to create our folder. It could be something like the following:

mkdir demo-static-deployment

Now, we’ll change the working directory to our newly created one.

cd demo-static-deployment

Let’s initialize the package.json and git for our directory.

yarn init -ygit init

I am using yarn package manager in this article, but feel free to use npm if you like. …

banner image showing a laptop with an open terminal, a coffee cup to the left of the laptop and a notepad to the right.
banner image showing a laptop with an open terminal, a coffee cup to the left of the laptop and a notepad to the right.
Illustration from

Idem-what now?

If you have been working with APIs, chances are that you might have heard some of your peers throw around the word “Idempotence”, leaving you to wonder what they really mean by that word anyway.

In this article we’ll look at a detailed answer; so we could learn what this fancy word “Idempotence” actually means in a REST API context.

After reading this article, the next time when your peer says that you need to make an endpoint idempotent, you will know exactly what they are talking about. So let’s get started:

Mathematics to The Rescue :

The word “Idempotent” has its roots in Mathematics…

Photo by Clint Patterson on Unsplash

In the modern web, APIs are like the nervous system. They transmit data to and from one endpoint to another and without them, the web, IoT and everything else that’s awesome about tech would not be so amazing.

When something is this crucial, it attracts a lot of attention and requires a lot of thoughts to be put in, while building one. For someone with malicious intent, unauthorized tapping on this nervous system of the web is all it takes to know what is going on within the system and worse, bring down the whole system.

In this article, let’s…

Class Diagram

What is Strategy Design Pattern?

Strategy design pattern is a behavioural design pattern. It is a tried and tested way of code design that can be used in scenarios where we need to pick up a specific approach (algorithm) from a pool of available related approaches during runtime to achieve something.

This design pattern is also sometimes referred to as the policy pattern.

In this article, let’s look at a practical scenario to utilize this design pattern and let’s write some code in Java to get a hands-on exposure.

The Scenario:

Let’s assume that we have our fictional application that contains some awesome articles and their corresponding…

Image comparison

Did you ever find yourself in a situation where you had a directory full of images and might have potential duplicates? To look through each image and mark duplicates will be a waste of your time, and so, you wanted to automate it with a script. But then, a few hours into it, you are reading some OpenCV documentation and articles and you didn’t know how you ended up there and worse, you realize, the rabbit hole is endless.

If the above situation sounds familiar, then this article is essential for you. If not, you will learn a neat trick…

Memory-optimized Javascript Object Instances

If you have been using JavaScript for a while, you would have come across the term “Constructor functions”, which are a fancy way to call a function that will be used as a blueprint to create object instances.

In a classical object-oriented language like Java, these blueprints will be classes. ( Even though we have the class keyword in JavaScript, it is not quite the same as their classical object-oriented counterpart. But let’s look at that in a different article at a later time).

In this article, let’s shift our focus towards looking at a way of creating memory-optimized instances…

Immutable Objects in JS

In this article, let’s look at a way to make objects in JavaScript immutable using the freeze method available on the Object prototype.

We will first explore what immutability is and why it is important. Then we will look at a code snippet in which we convert a normal object into an immutable one using the freeze method.

Finally, we will conclude by looking at the limitation of freeze()and also look at a quick approach to deep-freeze nested objects.

So, let’s get started.

What Is Immutability?

In the programming context, it means that the state (properties and methods) in an object are unchangeable…

Image Credit:

Hello fellow human, this will be one of those, once in a while article, where I don’t write about tech or programming but rather focus on something else that is equally, if not more important. Yeah, life it is.

So, recently I turned 30, and like every other millennial who turned 30, I spent a few moments on retrospection. After which, like most others, I decided to blog about it shamelessly. Yeah so predictable , I know ☺.

But what is in it for you, in this article? well, some learning and experiences. Some mistakes and lessons learnt and a…

Square Root Approximation Techniques

In this article let’s look at some square root approximation algorithms and techniques. We will start with a basic brute force approach and gradually improve its efficiency and sophistication.

In the real world we will never need to write an algorithm to calculate the square root of a number, as it is handled by the basic math package / module of almost all predominant programming languages.

Then why would we need to know it?, one might ask. Well, knowing this will deepen our understanding of how computers work with numbers in general and fractions in particular. …

Parthipan Natkunam

A software engineer by profession. Tinkers with electronics as a hobby. Loves literature and music. Likes to write and build things from scratch.

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