Skip to content

This repository is a comprehensive collection of well-documented and implemented design patterns in Python. This repository serves as a valuable resource for software developers and architects looking to understand and apply design patterns effectively in their Python projects.

Notifications You must be signed in to change notification settings

Dr4ks/Design_Patterns_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Hi, I'm Dr4ks! πŸ‘‹

πŸš€ About Me

I'm a Cyber Security student.

πŸ”— Links

linkedin hackerrank tryhackme github

πŸ›  Skills

Python

Design Patterns

Design patterns are proven solutions to recurring problems in software design. They are templates for solving similar problems in different contexts. Design patterns help in making software more modular, reusable, and maintainable.

Practical Examples

These design patterns which we covered with examples.

Adapter

The Adapter design pattern is a structural design pattern that allows incompatible interfaces to work together. It is useful when an existing class/interface cannot be modified to conform to the requirements of a new interface, or when there are multiple incompatible interfaces that need to be unified.

alt text

Example

Bridge

The Bridge design pattern is used to separate an abstraction from its implementation so that both can be changed independently. This pattern is useful when there are multiple implementations of a feature, and the client should be decoupled from the implementation details.

alt text

Example

Builder

The Builder design pattern is a creational pattern that allows for the step-by-step creation of complex objects. It separates the construction of an object from its representation, enabling the same construction process to create different representations. The pattern is useful when an object requires various configurations or when the creation process is complex and involves multiple steps.

alt text

Example

Chain of Responsibility

The Chain of Responsibility design pattern is a behavioral design pattern that allows a group of objects to handle a request, with each object either handling the request or passing it on to the next object in the chain.

alt text

Example

Command

The Command design pattern is a behavioral pattern that turns a request into a stand-alone object that contains all information about the request. This transformation allows for parameterizing other objects with different requests, queuing requests, and logging the requests. It also provides support for undoable operations.

alt text

Example

Composite

The Composite design pattern is a structural design pattern that lets you compose objects into a tree-like structure and work with the tree as if it was a singular object. The composite pattern allows you to create a hierarchy of objects where each object can be treated individually or as a part of a larger group.

alt text

Example

Decorator

The Decorator design pattern is a structural pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class.

alt text

Example

Facade

The Facade design pattern is a structural pattern that provides a simplified interface to a complex system of classes, interfaces, and objects. It is used to provide a single, unified interface to a set of interfaces in a subsystem, which makes the subsystem easier to use and understand.

alt text

Example

Factory-Method

The Factory-Method design pattern is a creational pattern that provides an interface for creating objects in a super class, but allows subclasses to alter the type of objects that will be created. This pattern is useful when you want to create a family of related objects but you don't know exactly what kind of objects you need to create until runtime.

alt text

Example

Iterator

The Iterator design pattern is a behavioral pattern that provides a way to access the elements of an aggregate object (such as a list) sequentially without exposing its underlying representation. It separates the concerns of traversal and collection, allowing multiple traversals of the same collection simultaneously.

alt text

Example

Observer

The Observer design pattern is a behavioral design pattern that allows one-to-many communication between objects in a loosely coupled manner. In this pattern, an object (called the subject) maintains a list of its dependents (called observers) and notifies them automatically of any state changes, usually by calling one of their methods.

alt text

Example

Proxy

The Proxy design pattern is a structural pattern that allows us to provide a surrogate or placeholder for another object to control access to it. It provides a way to add an extra level of indirection to support distributed, controlled, or intelligent access.

alt text

Example

Singleton

The Singleton design pattern is a creational design pattern that restricts the instantiation of a class to one single instance and provides a global point of access to that instance. This can be useful when there should be only one instance of a class in the system, such as in the case of a configuration manager or a database connector.

alt text

Example

State

The State design pattern is a behavioral pattern that allows an object to change its behavior when its internal state changes. This pattern is useful when an object's behavior depends on its state and needs to perform different actions based on that state. By encapsulating each state in a separate class, the State pattern promotes cleaner code by reducing conditional complexity.

alt text

Example

Strategy

The Strategy design pattern is a behavioral design pattern that allows you to define a family of algorithms, encapsulate each one, and make them interchangeable at runtime. This pattern allows the algorithms to vary independently from the clients that use them. In this way, you can use this pattern to choose the algorithm that best suits a particular problem, context or situation at runtime.

alt text

Example

Template-Method

The Template Method design pattern is a behavioral pattern that allows you to define the skeleton of an algorithm in a superclass but lets you override specific steps of the algorithm in subclasses. This pattern is useful when you want to define a set of steps that can be customized to fit a particular use case.

alt text

Example

Authors

About

This repository is a comprehensive collection of well-documented and implemented design patterns in Python. This repository serves as a valuable resource for software developers and architects looking to understand and apply design patterns effectively in their Python projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages