Go Design Pattern: Facade

What is Facade Pattern? The Facade pattern is a structural design pattern that provides a simplified interface to a complex subsystem. It acts like a friendly receptionist at a large corporation - instead of navigating through multiple departments and complex procedures, you just tell the receptionist what you need, and they handle all the complexity behind the scenes. I’ll demonstrate how this pattern can dramatically simplify client code and hide the complexity of intricate systems in Go applications....

May 5, 2024 · 8 min · Rafiul Alam

Go Design Pattern: Decorator

What is Decorator Pattern? The Decorator pattern is a structural design pattern that allows you to add new functionality to objects dynamically without altering their structure. It provides a flexible alternative to subclassing for extending functionality. Think of it like adding layers of clothing - each layer adds functionality (warmth, style, protection) while keeping the core person unchanged. I’ll show you how this pattern can help you build flexible, composable systems in Go that follow the open/closed principle....

April 10, 2024 · 6 min · Rafiul Alam

Introducing Scribe Menu

Why and how the idea of Scribe Menu came to my mind? One of my new year resolutions was to write a blog post every month on coding and productivity tips. Each blog post should be short enough for learners to go through all the topics quickly but also long enough to contain essential information. English not being my native language, I needed a tool to proofread my works. I used ChatGPT for the purpose....

March 16, 2024 · 3 min · Rafiul Alam

Go Design Pattern: Prototype

What is Prototype Pattern? The Prototype pattern is a creational design pattern that allows you to create new objects by cloning existing instances rather than creating them from scratch. It’s particularly useful when object creation is expensive or complex, and you want to avoid the overhead of initializing objects repeatedly. Think of it like having a template or blueprint that you can copy and modify as needed. I’ll demonstrate how this pattern can significantly improve performance and simplify object creation in Go applications....

March 15, 2024 · 6 min · Rafiul Alam

Go Design Pattern: Builder

📚 Go Design Patterns 🔨Creational Pattern ← Adapter Pattern 📋 All Patterns Strategy Pattern → What is Builder Pattern? The Builder pattern is a creational design pattern that constructs complex objects step by step. It allows you to produce different types and representations of an object using the same construction code. Think of it like assembling a custom computer - you choose the CPU, RAM, storage, and graphics card piece by piece to build exactly what you need....

February 27, 2024 · 10 min · Rafiul Alam

Go Design Pattern: Strategy

📚 Go Design Patterns 🎯Behavioral Pattern ← Builder Pattern 📋 All Patterns Decorator Pattern → What is Strategy Pattern? The Strategy pattern is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable. It lets you select algorithms at runtime without altering the code that uses them. Think of it like choosing different routes to reach the same destination - each route (strategy) gets you there, but some might be faster, cheaper, or more scenic....

February 13, 2024 · 9 min · Rafiul Alam

Go Design Pattern: Observer

What is Observer Pattern? The Observer pattern is a behavioral design pattern that defines a one-to-many dependency between objects. When one object (the subject) changes state, all its dependents (observers) are notified and updated automatically. Think of it like a newsletter subscription - when new content is published, all subscribers get notified. I’ll demonstrate this pattern with a practical scenario that shows how powerful it can be in Go applications....

January 30, 2024 · 7 min · Rafiul Alam

Go Design Pattern: Factory

What is Factory Pattern? The Factory pattern is a creational design pattern that provides an interface for creating objects without specifying their exact classes. It’s like having a factory that produces different types of products based on what you request, but you don’t need to know the intricate details of how each product is made. I’ll walk you through a practical scenario that demonstrates the power of the Factory pattern in Go....

January 16, 2024 · 4 min · Rafiul Alam

Go Design Pattern: Adapter

📚 Go Design Patterns 🏗️Structural Pattern 📋 All Patterns Decorator Pattern → 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....

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