Reproduced Common design Patterns in Java

Source: Internet
Author: User

Common design Patterns in Java

1. Single-case mode

The singleton mode has the following characteristics:
  1, the Singleton class can have only one instance.
  2, the Singleton class must create its own unique instance.
  3. The Singleton class must provide this instance to all other objects.
Singleton mode ensures that a class has only one instance, and instantiates itself and provides this instance to the entire system.

In short, the selection of Singleton mode is to avoid inconsistent state, to avoid long-running political.

Recommended Link: http://blog.csdn.net/jason0539/article/details/23297037

2. Factory mode

Two scenarios for Factory mode:
1. You cannot foresee what kind of instance you need to create at the time of encoding.
2. The system should not rely on the details of how product class instances are created, combined, and expressed

Recommended Link: http://www.cnblogs.com/poissonnotes/archive/2010/12/01/1893871.html

3. Build the Model

This pattern actually means that the composition of an object may be composed of many other objects, for example, the implementation of an object is very complex, there are many properties, and these properties are references to other objects, which may include a lot of object references. By encapsulating these complexities, you can use the build mode.

Recommended Link: http://www.cnblogs.com/cbf4life/archive/2010/01/14/1647710.html

4. Façade mode

This pattern feels like a replica of the service layer. For example DAO we define a lot of persistence methods, we use the service layer to make the DAO atomic method into business logic, and then provide services to the upper layer through the method.

    • Provides a simple interface for a complex subsystem
    • Improve the independence of subsystems
    • In a hierarchical structure, you can use the facade pattern to define the entry for each layer in the system

Recommended Link: http://www.cnblogs.com/skywang/articles/1375447.html

5. Policy mode

I feel like I haven't found a particularly good blog, which may be a bad appetite. Small series like to use real examples of the blog. The following links are explained in section 36,000.

Recommended Link: http://baike.so.com/doc/1838412-1944078.html

Reproduced Common design Patterns in Java

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.