2015.09.03 Java Design pattern

Source: Internet
Author: User

Typically, a design pattern describes a scenario that is proven feasible. These scenarios are very common and are the most commonly used patterns with a complete definition. The general pattern has 4 basic elements: The pattern name, the problem (problem), the solution (solution), and the effect (consequences).

Common Java Design Patterns have the following 23 types:

1. Abstract Factory: Provides an interface to create a series of related or interdependent objects without specifying their specific classes.

2. Adapter mode (Adapter): Transforms the interface of one class into another interface that the customer wants. The adapter mode makes it possible to work with classes that are otherwise incompatible with interfaces or classes that cannot work together.

3. Bridge mode: Separates the abstract part from its implementation, so that they can all change independently.

4. Build mode (builder): separates the construction of a complex object from its representation so that the same build process can create different representations.

5, responsibility Chain mode (Chain of Responsibility): to unbind the sender and receiver of the request, so that multiple objects have the opportunity to process the request. Link the objects together and pass the request along the chain until an object handles it.

6. Command mode: Encapsulates a request as an object, allowing the client to be parameterized with different requests, queuing or logging the request log, and supporting operations that can be canceled.

7. Compositing mode (Composite): Combines objects into a tree structure to represent a "partial-whole" hierarchy. It enables customers to have consistent use of individual objects and composite objects.

8. Decoration mode (Decorator): Dynamically add some additional responsibilities to an object. In terms of extension functionality, it is more flexible in the way it can generate subclasses.

9. Façade mode (facade): Provides a consistent interface for a set of interfaces in a subsystem, and the façade pattern defines a high-level interface that makes the subsystem easier to use.

10, Factory Methods (Factory method): Define an interface for creating objects, and let subclasses decide which class to instantiate. The Factory Method defers the instantiation of a class to its subclasses.

11, enjoy meta-mode (Flyweight): The use of shared technology to effectively support a large number of fine-grained objects.

12, Interpreter mode (interpreter): Given a language, define a representation of its syntax, and define an interpreter that interprets the sentences in the language using that representation.

13. Iterative sub-pattern (Iterator): Provides a way to sequentially access individual elements in an aggregated object without exposing the object's internal representation.

14. Mediator Mode (mediator): Use a Mediation object to encapsulate a series of object interactions. The mediator makes the objects do not require an explicit internal representation.

15. Memo Mode (Memento): captures the internal state of an object without destroying the encapsulation, and saves the state outside the object. The object can then be restored to the saved state.

16. Observer mode (OBSERVER): Defines a one-to-many dependency between objects so that when the state of an object changes, all objects that depend on it are notified and refreshed automatically.

17. Original model Mode (PROTOTYPE): Specifies the kind of object created with the prototype instance, and creates a new object by copying the prototype.

18. Proxy Mode: Provides a proxy for other objects to control access to this object.

19. Singleton mode (Singleton): guarantees that a class has only one instance and provides a global access point to access it.

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

21. Strategy Mode (Strategy): Define a series of algorithms, encapsulate them one by one, and make them interchangeable with each other. This mode allows the algorithm to be changed independently of the customer using it.

22. Template method: Defines the skeleton of an algorithm in an operation, and delays some steps into subclasses. The template method allows subclasses to redefine some specific steps of the algorithm without altering the structure of an algorithm.

23. Visitor Mode (Visitor): Represents an operation that acts on elements in an object's structure. This pattern enables you to define new actions that act on these elements without changing the class of each element.

2015.09.03 Java Design pattern

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.