Java 23 design pattern learning.

Source: Internet
Author: User

I. 3 category Design Patterns: Created, structured, behavioral.

A.5 Model: Factory method, abstract factory, Singleton, builder, prototype.

B.7 Model: Adapter, decorator, agent, appearance, bridging, combination, and enjoy.

c.11 Behavioral Patterns: Strategies, template methods, observers, iterations, chains of responsibility, commands, memos,

State, visitor, mediator, interpreter.

Note: In addition to the above 3 categories, there are another 2 types of design patterns: and hairstyles, thread pool.

Two. Design mode 6 major principles: Open and Close, the Richter substitution, dependence reversal, interface isolation, Dimitri (least known), synthetic multiplexing.

A. Open and close: to expand development, to modify the closure. When the program is expanded, the original code cannot be modified, and we need to use interfaces and abstract classes.

B. Richter substitution (LSP): One of the fundamental principles of object-oriented design, supplemented by the principle of closure. Where any base class can appear, subclasses must appear. Subclass inherits the base class, without affecting the base class, adding new methods and functions, the base class code can be reused.

C. Dependency reversal: The basis of the open and close principle, programming for the interface, depends on the abstraction does not depend on the specific.

D. Interface isolation: Using multiple isolation interfaces is better than using a single interface.

E. Dimitri (least known): An entity should have as few interactions as possible with other entities, making the system function modules relatively independent.

F: Synthetic multiplexing Principle: use synthesis/aggregation as much as possible instead of inheritance.

Three. 23 Design modes.

1.3 Plant Method modes: General factory, multiple plant methods.

A. General factory: Establish a factory class to create an instance of the class that implements the same interface.

Parent interface:

 Public Interface sender{     publicvoid  Send ();

Implementation class:

 Public class Implements sender{  @Override   publicvoid  , Send () {    System.out.println ("This is mailsender! " );  }}


Java 23 design pattern learning.

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.