Skip to content

The intent of this repo is to provide examples for each of the 23 Gang of Four design patterns

Notifications You must be signed in to change notification settings

matheusguermandi/gof-design-patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Introduction

Welcome Here! The intent of this repo is to provide examples for each of the 23 Gang of Four design patterns

📒 Design Patterns

Design patterns are typical solutions to commonly occurring problems in software design. They are like pre-made blueprints that you can customize to solve a recurring design problem in your code.

🔨 Creational Patterns

These patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code.

  • Abstract Factory
    • Define an interface or abstract class for creating families of related (or dependent) objects but without specifying their concrete sub-classes
  • Builder
    • Construct a complex object from simple objects using step-by-step approach.
  • Factory Method
    • Define an interface or abstract class for creating an object but let the subclasses decide which class to instantiate.
  • Prototype
    • Cloning of an existing object instead of creating new one and can also be customized as per the requirement.
  • Singleton
    • Define a class that has only one instance and provides a global point of access to it

🚡 Structural Patterns

These patterns explain how to assemble objects and classes into larger structures while keeping these structures flexible and efficient.

  • Adapter
    • Converts the interface of a class into another interface that a client wants.
  • Bridge
    • Decouple the functional abstraction from the implementation so that the two can vary independently.
  • Composite
    • Allow clients to operate in generic manner on objects that may or may not represent a hierarchy of objects.
  • Decorator
    • Attach a flexible additional responsibilities to an object dynamically.
  • Facade
    • Provide a unified and simplified interface to a set of interfaces in a subsystem, therefore it hides the complexities of the subsystem from the client
  • Flyweight
    • Reuse already existing similar kind of objects by storing them and create new object when no matching object is found
  • Proxy
    • Provides the control for accessing the original object

🔗 Behavioral Patterns

These patterns are concerned with algorithms and the assignment of responsibilities between objects.

  • Chain of Responsibility
    • Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.
  • Command
    • Encapsulate a request under an object as a command and pass it to invoker object. Invoker object looks for the appropriate object which can handle this command and pass the command to the corresponding object and that object executes the command.
  • Iterator
    • Access the elements of an aggregate object sequentially without exposing its underlying implementation.
  • Mediator
    • Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently.
  • Memento
    • Without violating encapsulation, capture and externalize an object's internal state so that the object can be returned to this state later.
  • Observer
    • Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
  • State
    • Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
  • Strategy
    • Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently of the clients that use it.
  • Template Method
    • Define the skeleton of an algorithm in an operation, deferring some steps to client subclasses.
  • Visitor
    • Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.

About

The intent of this repo is to provide examples for each of the 23 Gang of Four design patterns

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages