[Reading Notes] Big talk Design Model 1]

Source: Internet
Author: User
Tags switch case

Large

Big talk Design Pattern This book gives me the biggest feeling that this book is not written to illustrate the design pattern, it is to let you better understand, better understand and exist. So far, I have read half of it. I will summarize it a little bit.

0. UML class diagram.

The basis of software engineering is the UML class diagram. Dependency: Changes in element a will affect Element B, but vice versa. The relationship between B and A is dependency, and between B and A is dependent on a. It is represented by a dotted line with arrows, the arrow points to the depended element. Generalization: Generally speaking, the Inheritance (special individual is kind of general individual) relationship does not need to be explained. In UML, the solid line with a hollow arrow is represented, and the arrow points to a general individual. Implementation: this relationship is most commonly used for interfaces. In UML, hollow arrows and dotted lines are used to represent the realize relationship. Arrows point to elements that define conventions. Association: the structural relationship between elements. It is a weak relationship. The associated elements can be considered independently. In UML, the solid line is represented, and the arrow points to the dependent element. Aggregation: a special case of association, indicating the relationship between the partial and the overall (overall has a part. In UML, the solid line with a hollow diamond header is used to represent the aggregation relationship, and the diamond header points to the whole. Combination: A combination is a variant of the aggregation relationship, indicating a stronger combination between elements. If it is a composite relationship, if the whole is damaged, the individual will be damaged, while the aggregated individual may be shared by multiple entities, it may not be damaged as a whole. In UML, a solid line with a solid diamond header is used to indicate the composition relationship. The diamond header points to the whole.

1. Simple factory mode: instantiate through factory. Generally, switch is used for Branch in the factory.

2. Policy mode: Example: The specific algorithm inherits the abstract algorithm.

3. Single Responsibility Principle (Omitted) and open and closed principle (Omitted): As the name suggests. Dependency inversion principle: the high-level module does not depend on the underlying module, and both of them depend on abstraction. Abstraction does not depend on details, and details depend on abstraction.

4. decoration mode: dynamically add additional features to an object. The biggest feature is chained calling (wearing clothes)

5. Proxy mode: provides a proxy for other objects to control access to objects.

6. Factory method: the switch case of a simple factory is moved to the client code for implementation.

7. prototype: copy a resume in clone mode. Pay attention to the deep copy and shallow copy modes.

8. template method mode: Example: perform multiple choice questions for the exam, and place some abstract operations into sub-classes (answer1 () to achieve maximum code reuse.

9. dimit law: if two classes do not need to communicate with each other, they should not have a direct effect. (Assigned to the computer Repairer)

10. Appearance pattern: design a appearance class to know which sub-system classes are responsible for processing requests and delegate customer requests to appropriate sub-system objects.

11. Builder mode: design an abstract interface that contains all the abstract methods required for construction and must be implemented. The advantage is to separate the Construction Code from the representation code.

12. Observer mode: Used in the URL phishing system. It is characterized by notify. In this case, all registered classes of notify are processed.

13. Abstract Factory model: There may be factories that produce multiple products (SQL, access), and products that implement different abstract product parent classes. The book also mentions the extended content: replace with a simple factory and use reflection + Abstract Factory (convert different implementations into strings and replace them as needed), read the string with the configuration file (get rid of hard encoding)

14. Status mode: to eliminate long methods (such as switch statements), describe them using different status classes.

15. Adapter mode: translation, equivalent to the driver, a bit similar to the proxy mode.

16. Memorandum mode: modularization of initiators, memos, and players (managers.

17. Combination Mode: similar to the multi-tree structure in the data structure.

?

?

?

?

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.