Skip to content

Collection of 23 Gang of Four design patterns implementations in C#.

License

Notifications You must be signed in to change notification settings

Tearth/Design-Patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design Patterns

Collection of 23 Gang of Four design patterns implementations in C#. Done mainly for learning purposes but feel free to use them however you want.

Behavioral patterns

Define the ways of communication between objects.

  • Chain of Responsibility - handles data by passing it between objects in the chain
  • Command - encapsulates command/request into separate class
  • Interpreter - executes expressions
  • Iterator - sequental access to the elements in the collection
  • Mediator - communication between objects using separate class
  • Memento - saves and restores object state
  • Observer - notifies objects about some event
  • State - alters class behaviour
  • Strategy - encapsulates algorithms to the separate classes
  • Template Method - overrides (by creating subclasses) steps of the algorithm
  • Visitor - adds new operation to the class without its change

Creational patterns

Define the ways of creating objects using hidden logic instead of directly new keyword use.

  • Abstract Factory - creates instances of the specified class family
  • Builder - constructs instances with a few steps
  • Factory Method - creates instances of the derived classes
  • Prototype - creates instance by copying or cloning other object
  • Singleton - ensures that there is only one instance of the class

Structural patterns

Define the ways of composing objects and classes to add or change functionality.

  • Adapter - matches interfaces of different classes
  • Bridge - separates interface from its implementation
  • Composite - composes object using tree structure
  • Decorator - adds new responsibilities to the existing class
  • Facade - class representing a few subsystems
  • Flyweight - small and reusable objects
  • Proxy - controlls the access to the object