Agent mode, decoration mode, adapter mode, combination mode, bridge mode, appearance mode, enjoy meta mode "Reading Notes" design mode Chapter 4: Structural mode

Source: Internet
Author: User
I have made reference to the routines in the book to recreate some of the more vivid, easy to understand examples, I hope you like. The code can be browsed through the following links: Http://git.oschina.net/caipeichao/java-design-pattern

A structured pattern describes how to combine objects or classes to form a more powerful structure.
The proxy mode definition is also called delegate mode, which provides a proxy for other objects. To control the access role of this object: abstract role, real role, Agent role Type: Remote proxy (access to additional JVM), virtual agent (delay to create unwanted parts), protection agent, cache proxy, synchronization agent, Smart reference agents (such as logs) the advantages of responsibility clear high scalability Intelligent: At run time it is determined that the real object used by the agent is very extensive, for example, the RMI AOP decorative pattern Definition dynamically adds additional responsibilities to an object: abstract artifacts, concrete artifacts, decorative roles, specific decorative roles, decorative features, and The decorated class can be independently developed and will not be coupled with decorative patterns that are inherited alternative decorative patterns can dynamically extend an object's functional disadvantage multilayer decoration more complex use scenarios need to extend the function of a class need to dynamically add functionality to an object need to modify or add functionality to a group of classes Many of the Javaio are decorated mode adapter pattern definition also called transformer mode to convert the interface of one class to another, the advantages of two are not related classes are run together to increase the transparency of the class to increase the reusability of the class to enhance the flexibility of the code using the scenario to modify an operating system the system needs to be Extension, there is already a class, this class does not conform to the interface in the system, which requires the adapter to transform the interface combination mode definition and the compositing pattern to combine the objects into a tree structure representation, making the whole and part of a consistent role: abstract parts, leaf parts, branch parts advantages high-level module calls relatively simple node free increase The part type that is not easy to control the branch is not easy to use the inheritance method to add new behavior using the scene menu, files such as the need for the client to ignore the overall and local differences, equal treatment of all Components bridge mode definition is also called bridging mode, is an unusual pattern of the abstraction and implementation of the solution coupling, so that the two can be independently changed Roles: abstracting roles, correcting abstract roles, implementing roles, implementing roles, and implementing the role of abstraction and implementation separation, implementation can be free from abstract constraints clients do not care about implementation details increase flexibility and extensibility use if more flexibility is needed between abstraction and implementation Changes to the implementation of the client is completely unaffected by dynamic coupling where you do not want to inherit the implementation of partial-appearance mode definition in C + + can be completely hidden in cross platform application the façade mode requires that the subsystem communicate with the external communication through a unified object: Appearance role, subsystem role benefits reduce system project Dependency improvement Flexibility to enhance security use scenario Hope subsystem provides external access interface subsystem relative independent prevention of risk diffusion mode definition is an important implementation of pool technology using shared technology can effectively reduce the number of fine-grained operations generated by the OpenThe pins are divided into internal state and external status roles: abstract, specific enjoy yuan, the benefits of the factory, the advantages of the client significantly reduce the memory cost of the system to increase the complexity of the system of the state of the element mode of externalities, so that the external state of the running time longer use the scene system has a large number of similar object objects operation does not require a specific identity The scenario Java for which a buffer pool is needed is a pattern in the element, such as String integer.

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.