Revise with me. Part 5. Design Patterns [EN]

Revise with me. Part 5. Design Patterns [EN]

"Devie Into Design Patterns" Books:

Микросервисы. Паттерны разработки и рефакторинга

Generative Design Patterns:

  • Factory Method defines a common interface for creating objects in a superclass, allowing subclasses to change the type of objects they create.
  • Abstract Factory allows you to create families of related objects without being tied to the specific classes of objects that you create.
  • Builder lets you create complex objects step by step. The builder makes it possible to use the same building code to get different representations of objects.
  • Prototype allows objects to be copied without going into the details of their implementation.
  • Singleton ensures that a class has only one instance and provides a global access point to it.

Structural Design Patterns:

  • Adapter allows objects with incompatible interfaces to work together.
  • Bridge separates one or more classes into two separate hierarchies - abstraction and implementation, allowing them to be modified independently of each other.
  • Composite allows you to group multiple objects into a tree structure and then work with it as if it were a single object.
  • Decorator allows you to dynamically add new functionality to objects by wrapping them in useful wrappers.
  • Facade provides a simple interface to a complex class system, library, or framework.
  • Flyweight allows more objects to fit into allocated RAM. The lightweight saves memory by sharing the common state of objects among themselves, instead of storing the same data in each object.
  • Proxy allows you to substitute special proxy objects in place of real objects. These objects intercept calls to the original object, allowing you to do something before or after passing the call to the original.

Behavioral Design Patterns:

  • Chain of Responsibility allows requests to be passed sequentially through a chain of handlers. Each subsequent handler decides whether it can process the request itself and whether it is worth passing the request further down the chain.
  • Command turns requests into objects, allowing them to be passed as arguments when calling methods, enqueued and logged requests, and support cancellation of operations.
  • Iterator allows you to sequentially traverse the elements of composite objects without revealing their internal representation.
  • Mediator allows you to reduce the coupling of multiple classes to each other by moving those relationships into a single mediator class.
  • Snaphsot allows you to save and restore past states of objects without disclosing implementation details.
  • Observer creates a subscription mechanism that allows one object to monitor and respond to events occurring in other objects.
  • State allows objects to change behavior based on their state. From the outside, it seems that the class of the object has changed.
  • Strategy defines a family of similar algorithms and puts each of them in its own class, after which the algorithms can be interchanged right at runtime.
  • A Template Method defines the skeleton of an algorithm, shifting responsibility for some of its steps to subclasses. The pattern allows subclasses to override the steps of an algorithm without changing its overall structure.
  • Visitor allows you to add new operations to a program without changing the classes of objects on which these operations can be performed.

Sources:

要查看或添加评论,请登录

社区洞察

其他会员也浏览了