Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Basic concepts of classical design patterns in 23

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Abstract Factory: provides an interface for creating a series of related or interdependent objects without specifying their specific classes.

Adapter: converts the interface of one class to another interface that the customer wants. The A d a p t e r pattern allows classes that cannot work together because of interface incompatibility.

Bridge: separate the abstract part from its implementation part so that they can all change independently.

Builder: separate the construction of a complex object from its representation so that the same build process can create different representations.

Chain of Responsibility: in order to uncouple the sender and receiver of the request, multiple objects have the opportunity to process the request. Concatenate these objects into a chain and pass the request along the chain until an object processes it.

Command: encapsulates a request as an object so that you can parameterize customers with different requests; queue or log requests; and support cancelable operations.

Composite: combine objects into a tree structure to represent a "part-whole" hierarchy. It makes the customer's use of single object and composite object consistent.

Decorator: dynamically add some additional responsibilities to an object. In terms of extended functionality, it is more flexible than generating subclasses.

Facade: provides a consistent interface for a set of interfaces in a subsystem, and the Facade pattern defines a high-level interface that makes the subsystem easier to use.

Factory Method: define an interface for creating objects and let subclasses decide which class to instantiate. Factory Method delays the instantiation of a class to its subclasses.

Flyweight: use sharing technology to effectively support a large number of fine-grained objects.

Interpreter: given a language, define a representation of its grammar and define an interpreter that uses that representation to interpret sentences in the language.

Iterator: provides a way to access elements of an aggregate object sequentially without exposing the internal representation of the object.

Mediator: use a mediation object to encapsulate a series of object interactions. Intermediaries make objects do not need to explicitly reference each other, so that they are loosely coupled, and can change the interaction between them independently.

Memento: without breaking the encapsulation, capture the internal state of an object and save that state outside the object. This allows you to restore the object to its saved state later.

Observer: defines an one-to-many dependency between objects so that when the state of an object changes, all objects that depend on it are notified and automatically refreshed.

Prototype: specify the type of object to be created with a prototype instance, and create a new object by copying the prototype.

Proxy: provides a proxy for other objects to control access to this object.

Singleton: make sure that there is only one instance of a class and provide a global access point to it.

State: allows an object to change its behavior when its internal state changes. The object appears to have modified the class to which it belongs.

Strategy: define a series of algorithms, encapsulate them one by one, and make them interchangeable. This mode makes the change of the algorithm independent of the customers who use it.

Template Method: define the skeleton of an algorithm in operation and defer some steps to subclasses. Template Method enables subclasses to redefine certain steps of an algorithm without changing the structure of the algorithm.

Visitor: represents an operation that acts on elements in an object structure. It allows you to define new operations that act on individual elements without changing their classes.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report