Head First Design Patterns

Source: Internet
Author: User
Tags inheritance
Take a look at the Design Pattern lessons before making a bigger plan.
After reading the demo chapter about Decorator in Head First Design Patterns, we found that the JOLT Award is not from the white list, and the presentation is clear because of its strong narrative ability, not those old gentlemen who are full of brains can compare. In addition, the entire Pattern presentation process is gradual, and it can be ensured that little Bai can learn the design Pattern.
Unfortunately, there is only one chapter. The Head First series of e-books are not easy to find, so I had to go through the books of the old gentlemen.
In fact, the GOF80 % pattern is based on one principle:
Object combination is preferred, rather than class inheritance.
Beginners of OO are used to map the world of programs in the real world. Inheritance is the most natural idea. GOF is actually reversing this idea and making everyone accustomed to using combinations, delegation, and program objects.
The combination mechanism can change the vast majority of the GOF mode based on the two principles. 1. any coupling can be done by adding an intermediate layer to decouple the representative modes: Facade, Mediator, Adapter and Factory/Abstract Factory, Proxy 2. object features can be expanded through combination to avoid class explosion caused by pure inheritance. The representative modes include Bridge, Decorator, Chain of Response, Strategy/Command.
3. Some independent common modes such as Singleton, Visitor, and Observe
Replay slow mirror: 1. Facade: to reduce the coupling between one system and the other system's internal classes. Main functions of object A proxy system
2. Mediator: to reduce coupling between two objects. Create an intermediate object C with instances A and B at the same time, and assign C to A and B
3. Adapter: use the same interface to match different objects. Create the method of object B, proxy A, and make its interface match.
4. factory: create an object that depends on the interface to not depend on a specific object. The program obtains the object through the Factory.
5. Proxy: in addition to not relying on specific objects, you can also insert actions in the process. The program calls the object's method (AOP) through Proxy)
6. Bridge: If object features develop in two directions, Bridge can avoid class explosion caused by the arrangement and combination of object features. A group of features, such as a big cup or a medium cup, a group of features such as milk and sugar. Separates a group of feature abstractions into Interface 2, and passes the instance of interface 2 to the master inheritance tree.

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.