Basic concepts of common design patterns

Source: Internet
Author: User

Design Pattern: a solution that is verified in software development and used to solve repeated and specific problems in a specific environment.

Design Pattern Classification

  • Creation Mode: abstracts the Object Instantiation process to help create an object instance.
  • Structural mode: describes how to combine classes and objects to obtain a larger structure.
  • Behavior mode: Describes the assignment of duties between algorithms and objects.

Common Design Patterns

  • Simple Factory: provides the function of creating an object instance without worrying about its specific implementation. The instance to be created can be an interface, an abstract class, or a specific class.
  • Appearance mode: provides a consistent interface for a group of interfaces in the subsystem. The facade mode defines a high-level interface, which makes the subsystem easier to use.
  • Adapter mode: converts an interface of a class to another interface that the customer wants. The adapter mode allows the classes that cannot work together due to interface incompatibility to work together.
  • Singleton mode: ensures that a class has only one instance and provides a global access point to access it.
  • Factory method mode: defines an interface for creating objects, so that the subclass determines which class to instantiate. Factory method delays the instantiation of a class to its subclass.
  • Abstract Factory mode: provides an interface for creating a series of related or mutually dependent objects without specifying their specific classes.
  • Generator mode: separates the construction of a complex object from its representation, so that different representations can be created during the same construction process.
  • Prototype: Use a prototype instance to specify the object type and copy the prototype to create a new object.
  • Intermediary mode: a mediation object is used to encapsulate a series of object interactions. The intermediary makes it unnecessary for objects to explicitly reference each other, so that the coupling is loose and the interaction between objects can be changed independently.
  • Proxy mode: provides a proxy for other objects to control access to this object.
  • Observer mode: defines a one-to-many dependency between objects. When an object state changes, all objects dependent on it are notified and updated automatically.
  • Command mode: encapsulate a request as an object, so that you can parameterize the customer with different requests, arrange or record request logs for requests, and support auditable operations.
  • Iterator mode: provides a method to access each element of an aggregate object sequentially without exposing the internal representation of the object.
  • Combination Mode: combines objects into a tree structure to represent a "part-whole" hierarchy. The combination mode ensures consistency between the use of a single object and a composite object.
  • Template Method mode: defines the skeleton of an operation algorithm, and delays some steps to the subclass. The template method allows the subclass to redefine the specific steps of an algorithm without changing the structure of an algorithm.
  • Rule mode: defines a series of algorithms, encapsulates them one by one, and enables them to replace each other. This mode allows the computing service to change independently of the customers who use it.
  • State mode: allows an object to change its behavior when its internal state changes. The object seems to have modified its class.
  • Memorandum mode: capture the internal state of an object without breaking the encapsulation, and save the state outside the object. In this way, the object can be restored to the previously saved state.
  • Sharing Mode: The sharing technology is used to effectively support a large number of fine-grained objects.
  • Interpreter mode: for a given language, define a representation of its syntax and define an interpreter which uses this representation to interpret sentences in the language.
  • Decoration mode: dynamically add some additional responsibilities to an object. The decoration mode is more flexible than the subclass generation function.
  • Responsibility Chain Mode: Enables multiple objects to process requests to avoid coupling between request senders and receivers. Connect these objects into a chain and pass the request along the chain until an object processes it.
  • Bridge Mode: separates abstract parts from their implementations so that they can all change independently.
  • Visitor mode: indicates an operation that acts on each element in an object structure. It allows you to define new operations that act on these elements without changing the classes of each element.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.