Go Design Pattern: Adapter

What is Adapter? The Adapter pattern is probably the most used design pattern in software engineering. It allows objects/classes of different abstracts/signatures/blueprints to collaborate. I will guide you through a practical scenario that will make it easier to understand the Adapter pattern. Let’s start with a scenario: Hack the API Suppose you are creating an OpenAI API client. It connects to the OpenAI client with a secret key. But you want to hack the client to communicate with the Hugging Face API instead....

January 2, 2024 · 4 min · Rafiul Alam

Go Design Pattern: Singleton

What is Singleton? The Singleton pattern is a design pattern that ensures a class has only one instance and provides a global access point to that instance. I will keep the post as simple as possible as our brain can process a little at a time (don’t know about yours, mine can’t). Let’s start with a scenario: Database connection You want to connect to the database of a service to fetch some information....

December 29, 2023 · 4 min · Rafiul Alam