) 23 Design Patterns

Source: Internet
Author: User

If you do not know what the design pattern is?

First, let's look at the design model introduction!

Java and mode directory

 

1. Preface

Learning the importance of gof Design Patterns

Similarities and differences between models in architecture and software

2: gof Design Mode
A.Creation Mode

Singleton (single-State/single-piece) of Design Pattern Dr. Yan explained: Singleton pattern
Ensure that a class has only one instance, and provide a global access point to it, which is updated on.

Factory of design pattern (Factory method and abstract factory)
The factory mode is updated as frequently as new. 2002/10/9

Design Pattern Builder
A car consists of many components of the wheel steering wheel engine. At the same time, assembling these components into a car is also a complicated task. The Builder mode is to separate the two situations.
Prototype of Design Pattern)
Use a prototype instance to specify the type of the object to be created, and copy the prototype to create a new object.

B. Structure Mode

Adapter in Design Mode)
There are two ways to use class regeneration: combination (new) and inheritance (extends), which have been mentioned in "thinking in Java.

Proxy in Design Mode)
Take jive as an example to analyze the application of proxy mode in user-level authorization mechanism

Facade in Design Mode ?)
The extensible use of JDBC for different database programming, facade provides a flexible implementation.

Composite (combination) of design patterns)
It is to combine the class with a tree structure into a unit. You introduce to others that you are a unit and you are an element in the unit. Other people are doing business with you, which is equivalent to doing business with the unit. The article further analyzes jive.
Decorator in Design Mode)
Decorator is a painter who painted your appearance with beautiful colors.
Bridge in Design Mode)
Separate the "Cowherd and Weaver girl" (they should have been separated to form two interfaces) and build a bridge between them (dynamic combination)
Design Pattern-flyweight (shared element)
Provides Java runtime performance to reduce the overhead of small and large repeated classes.

C. Behavior Pattern

Command in Design Mode)
Command is the best description of behavior encapsulation.
Design Pattern-Observer (observer)
Describes how to use the ready-made observer provided by Java APIs
Design Pattern iterator (iterator)
This mode has been integrated into the collection of Java. In most cases, you do not need to create an iterator, as long as you load the object into the collection, directly use iterator for object traversal.
Design Pattern template (template method)
In fact, I introduced Why JAVA abstract classes are used. This mode is simple in principle and widely used.
Strategy for Design Patterns)
Different algorithms are encapsulated, and users can select the desired algorithms at will.
Chain of responsibility of design patterns)
The classes of their respective duties are represented in a string, as if they are drumming and spreading flowers. Of course, if they can be completed by themselves, they should not be pushed to the next one.
Mediator in Design Mode)
Mediator is like a traffic light at a crossroads. Every vehicle only needs to interact with the traffic light.
State in Design Mode)
The status is an instance that is often encountered in programming. Status converter can be easily switched to the status by visualizing the status.
Memento in design mode (comment status ?)
A simple mode is to keep the original data copies in the memory.
Interpreter of design pattern (Interpreter)
It is mainly used for language analysis and has few application opportunities.
Design Pattern visitor (visitor)
Visitors complete a series of substantive operations during access, and can also expand.
3: Other Materials

JAVA Implementation in 23 design modes (source code is provided)

Another book by Eckel of thinking in patterns with Java thinking in Java!

Cmsc491d Design Patterns in Java
Overview of design patterns precisely defines various modes and Their Relationships
Design Patterns Java companion

The design pattern is used in EJB. This is an article I published in programmer 6th. It is easy to write.
I think the EJB Design mode is a very effective way to understand EJB or J2EE from the design mode.

 

  • Thanks to user David Yu for making the design mode into a PDF file. Here we download the PDF file

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.