neerajankam / design-patterns

Implementation of design patterns in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐Ÿ—๏ธ Design patterns

Design patterns are like tried-and-true blueprints, offering reusable solutions to common problems. They empower us to craft code that's not just functional, but also flexible and scalable.

There are three main categories of design patterns:

  1. Creational Patterns: These focus on object creation mechanisms.

    • Singleton 1๏ธโƒฃ: Guarantees only one instance of a class exists.
    • Factory Method ๐Ÿญ: Creates objects without locking them into a specific class.
    • Abstract Factory ๐Ÿญ: Produces families of related or dependent objects.
    • Builder ๐Ÿ‘จ๐Ÿพโ€๐Ÿญ: Separates complex object construction from its representation.
    • Prototype ๐Ÿงฌ: Clones objects for efficient instance creation.
  2. Structural Patterns: These deal with object composition and relationships.

    • Adapter ๐Ÿ›ฃ๏ธ: Makes different interfaces work together harmoniously.
    • Bridge ๐ŸŒ‰: Separates abstraction from implementation.
    • Composite ๐ŸŒฒ: Composes objects into tree structures for part-whole hierarchies.
    • Decorator ๐ŸŽŠ: Dynamically adds responsibilities to objects.
    • Facade ๐Ÿข: Offers a simplified interface to a subsystem.
    • Flyweight : Efficiently shares and reuses objects to minimize resource usage.
    • Proxy ๐Ÿ›‚: Acts as a placeholder for another object to control access.
  3. Behavioral Patterns: These dictate object interactions and communications.

    • Chain of Responsibility โ›“๏ธโ€๐Ÿ’ฅ: Passes a request along a chain of handlers.
    • Command ๐Ÿ—ฃ๏ธ: Encapsulates requests as objects for flexible execution.
    • Iterator ๐Ÿšš: Provides sequential access to elements in an aggregate object.
    • Mediator ๐Ÿ‘ฎ๐Ÿฝ: Encapsulates object interaction logic.
    • Memento ๐Ÿ†: Captures and externalizes an object's internal state.
    • Observer ๐Ÿ”Ž: Notifies objects of changes in state.
    • State ๐Ÿ“‘: Allows objects to change behavior when their internal state changes.
    • Strategy ๐Ÿ”Ž: Defines interchangeable algorithms for flexible usage.
    • Template Method ๐Ÿฉป: Establishes a skeleton algorithm with customizable steps.
    • Visitor ๐Ÿง๐Ÿฝ: Performs operations on elements of an object structure.

About

Implementation of design patterns in Python


Languages

Language:Python 100.0%