This is v2 of my Design Patterns blog. I decided to start fresh to better reflect my current understanding. Given the nature of my work, I mostly deal with decorators and iterators, so they’ll be the main focus of this post. That said, I’ll “inherit” all the core concepts of OOPs from v1 to creating a more cohesive and updated perspective on design patterns. The current iteration (April 12, 2025) of the blog is meant to stand on its own, but I’ll continue updating it as I learn new things.

Quick note: I’ve recently been diving deep into distributed systems and reading a lot about them so don’t be surprised if you see references or side notes ✌️

Design Pattern


Decorator pattern

By definition, the decorator pattern allows behavior to be added to an object dynamically without affecting the behavior of other objects from the same class. In essence, it enables us to extend an object’s functionality without modifying its underlying structure making it particularly useful for building flexible and reusable systems.

In python, one the widely used feature is decorate (syntactic sugar). Though the decorator pattern and python decorator share the same idea of wrapping functionality to extend behaviour, there are subtle difference

In Python, a commonly used feature is the decorator (syntactic sugar using @). While Python decorators and the decorator pattern share the core idea of wrapping functionality to extend behavior, there are subtle differences between them.

Over the course of my apprentice as a RE, I have created a few of these who have made my life easier

Inbuilt decorators and decorator library

  1. Method → @classmethod, @staticmethod, @property, @abstractmethod
  2. Class: @abstractclass, @dataclass
  3. Decorator libary: <To Add>

Reference resources:

The most obvious one is ChatGPT but inaddition to that Primer on decorator (Real Python), Design Pattern: Decorator (medium), Awesome Python Decorator (GitHub), Decorator (python wiki)