The Strategy Pattern is a popular design pattern used to organize as well as and encapsulate algorithms. This pattern is used when is necessary to isolate the business logic of a class from algorithm implementation details that may not be as important in the context of that logic.
The authors of the book Design Patterns: Elements of Reusable Object-Oriented Software define the Strategy Pattern as follows:
Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
The Strategy pattern is to be used where we want to…
Nowadays, more and more people are using online resources to communicate, giving presentations, working on projects or even creating music in online collaboration. Therefore, many tech companies are enhancing their services to provide a way to make this communication easy to scale, easy to use, more accessible, and more efficient.
In this article, we’ll learn how to create a peer-to-peer connection to establish a video chat between two or more users, without requiring the user to install plug-ins or any other third-party software.
WebRTC is a new front in the long war for an open and unencumbered web. …
The Factory Pattern is one of the core design pattern principles for creating an object. It allows clients to create objects using a common interface. In TypeScript, there are many different ways in which you can use the factory pattern to make your code cleaner and more concise. In this article, we’ll demonstrate how to create a factory pattern using TypeScript Generics.
The authors of the book Design Patterns: Elements of Reusable Object-Oriented Software define the Factory Pattern as:
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
In other words, the factory…
Also known as Dependents or Publish-Subscribe, the Observer pattern helps us create decoupled components and modules. It improves the testability, composition, and scalability of our applications. In this post, I’m going to show you some concepts around the Observer pattern, how it works, and a practical example.
The authors of the book Design Patterns: Elements of Reusable Object-Oriented Software defines Observer Pattern as:
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
We can think of the Observer pattern as a communication channel between two different modules or…
Singleton is one of the most used design patterns in software development. In this post, we will learn how to implement this pattern in the context of web development using TypeScript.
The authors of the book Design Patterns: Elements of Reusable Object-Oriented Software defines Singleton Pattern as:
A singleton class is a class that has a single object and that unique object constitutes a global facility for all clients.
Basically, the singleton pattern forces you to get an instance of the class via a class method or a getter. …
The AC-3 algorithm simplifies a constraint satisfaction problem using the constraints to prune out values from the variables domain.
In this article, we will see how the AC-3 algorithm works and the implementation in Python.
We can represent the AC-3 algorithm in 3 steps:
In my last post, I showed you how to configure, develop, and generate a WASM file via GoLang. In this post, I will show you the best practices and how to use these strategies in a real modern web project.
If you already generate a web assembly binary file using Go, you’ve probably noticed how big the file size is. As we load this binary file on a web page, it will affect the load of other assets on the page. It can affect Time to Interactive (TTI) as well. TTI measures how long it takes a page to become…
Today web and mobile applications are the primary vehicles for providing software solutions to users around the world. Applications that we had only in desktop apps today are available for browsers like graphics, photo and video editors; music and video players; and so on.
The goal of linear programming is to minimize a cost function that has some number of variables (x₁, x₂, x₃) all the way up to x𝑛. Those variables are involved in things that I want to know the values to, and they might be multiplied by a coefficient and then added together.
With linear programming, we are just dealing with linear equations, so we’re not going to square or cube anything.
Also, we’ll have some linear constraints:
With the following bound for…
When you have a Next.js application you probably use Styled JSX to write the style of your components. It is because Next.js includes Styled JSX by default in your project. If this is your case or you’re just using Styled JSX by yourself and you want to implement a Dark/Light mode switch on your website this article is for you.
The first step is to choose the right colors for your dark and light themes. Defining the…