Overview of Java Design Patterns

Source: Internet
Author: User

Objective

Design patterns are the best strategies that many developers have summed up in their repeated practice. Design patterns are often adopted by engineers with rich experience in software development. Design patterns are also a solution for development engineers who face general problems in the software development process. Design patterns are a highly summarized set of design experiences that have been used repeatedly by developers, most of whom are aware of, using design patterns at least two benefits.

1. Avoid the same code stickers everywhere.

2. Make the code understood and extended.

Use of design Patterns

    • Design patterns provide a standard term for any developer with a few years of experience in maintaining system code, what can be very fast code?
    • Design patterns have been a long process, providing some of the problems and best practices that are faced in the software development process.

Types of Design Patterns

Design patterns mentions that there are 23 designs in total, and these 23 models can be divided into three categories.

    • Create a pattern.

The creation mode mainly includes Factory mode, abstract Factory mode, singleton mode, builder mode and prototype mode. This type of design pattern emphasizes that when creating an object, you hide the way you create the logic, rather than instantiating the object directly with the new keyword, which makes the program more flexible in judging which objects need to be created for a given instance.

    • Structural mode.

Structure mode mainly has adapter mode, bridge mode, filter mode, combination mode, adorner mode, appearance mode, enjoy meta mode, proxy mode. A structured pattern focuses on the combination of classes and objects. The concept of inheritance is used to combine interfaces and define how composite objects acquire new functionality.

    • Behavioral Patterns .

Behavioral patterns are mainly responsible chain mode, command mode, interpreter mode, iterator mode, mediator mode, Memo mode, observer mode, state mode, empty object mode policy mode, template mode, visitor mode.

6 Principles of Design patterns

    • Opening and closing principle (open close principle), the open and closed principle means that the expansion of openness, to modify the closure, when the program needs to expand, do not modify the original code, that is, in order to make the program has good extensibility, easy to maintain and upgrade.
    • The principle of substitution of the Richter Scale (Liskov substitution principle): The principle of substitution on the Richter scale is one of the principles of object oriented design. Subclasses can add new behavior on the basis of a base class, that is, when a variable is declared, the base class type is used, the subclass type is determined at run time, and the behavior of the subclass is substituted by the behavior of the child class.
    • Dependency Reversal principle (dependence inversion principle): This principle is the basis of the open and close principle, emphasizing that programming for interfaces relies on abstraction rather than on specifics.
    • Interface Isolation principle (interface segregation principle): Using multiple isolated interfaces is better than using a single interface, i.e., reducing dependencies and reducing coupling.
    • Dimitri Law (Demeter principle): An entity interacts with other entities as little as possible, making the system function modules relatively independent.
    • Synthetic multiplexing principle (composite reuse principle): Use composition/aggregation as much as possible, rather than using inheritance.

The focus of design pattern interpretation

This topic talk about design patterns, I will focus on 5 points.

    • The basic concept of the design pattern.
    • The design pattern solves what the problem is.
    • The advantages and disadvantages of this design pattern.
    • The design pattern is applied in the JDK source code.
    • The application of the design pattern in spring source code.

Overview of Java Design Patterns

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.