Home > Java > javaTutorial > body text

What are design patterns

青灯夜游
Release: 2019-01-29 10:27:33
Original
14210 people have browsed it

A design pattern is a common, reusable, and known solution or template to common problems in software design; these solutions are obtained through trial and error by many software developers over a long period of time. of. Below we will introduce you to the design pattern, hoping it will be helpful to you.

What are design patterns

Uses of Design Patterns

Design patterns have two main uses in software development. [Video tutorial recommendation: Java Tutorial]

A universal platform for developers

Design patterns provide standard terminology and are specific to specific scenarios. For example, the Singleton design pattern represents the use of a single object, so all developers familiar with the Singleton design pattern will be using a single object, and they can tell each other that their programs follow the Singleton pattern.

Best Practices

Design patterns have been developed over a long period of time and they provide the best solutions to certain problems encountered during software development. Learning these patterns can help inexperienced developers learn software design in an easy and fast way.

Types of Design Patterns

Patterns usually show relationships and interactions between classes or objects. There are three main types of design patterns. Let’s introduce them respectively:

Creation pattern

Creation design pattern provides a way to create objects while hiding the creation logic. method instead of instantiating the object directly using the new operator. This increases flexibility and reuse of existing code in deciding which objects need to be created for a given use case.

Creation design patterns can be divided into: factory method, abstract factory, generator, singleton, object pool and prototype.

Structural Pattern

Structural design pattern is about combining different classes and objects to form larger structures and provide new functionality. Structural design patterns simplify structure by identifying relationships; it focuses on how classes inherit from each other and how they are composed of other classes.

Structural design patterns can be divided into: Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Private Class Data and Proxy.

Behavioral Patterns

Behavioral design patterns are about identifying common communication patterns between objects and implementing those patterns.

Behavioral design patterns can be divided into: Chain of Resposibility, command, interpreter, iterator, mediator, memento, and empty object (Null Object), observer (observer), state (state), strategy (strategy), template method (template method), visitor (visitor)

The above is the entire content of this article, I hope it can It will be helpful to everyone’s study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of What are design patterns. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template