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. …
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.
We could use the
mkdir command to create our folder. It could be something like the following:
Now, we’ll change the working directory to our newly created one.
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. …
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:
The word “Idempotent” has its roots in Mathematics…
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.
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.
Let’s assume that we have our fictional application that contains some awesome articles and their corresponding…
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…
In this article, let’s shift our focus towards looking at a way of creating memory-optimized instances…
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.
In the programming context, it means that the state (properties and methods) in an object are unchangeable…
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…
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. …
A software engineer by profession. Tinkers with electronics as a hobby. Loves literature and music. Likes to write and build things from scratch.