What are program design patterns?
There are three main types of design patterns: Creative, Structural, and Behavioral.x0a Among the Creative Patterns are:x0a i. Singleton, the Singleton Pattern: Ensures that there is only one instance of a class and provides a global access point to it.x0a ii. AbstractFactory, the abstract factory: Provides an interface for creating a set of related or interdependent objects without having to specify their concrete classes.x0a iii. objects without having to specify their concrete classes.x0a iii. FactoryMethod: defines an interface for creating objects and lets subclasses decide which class to instantiate; FactoryMethod delays the instantiation of a class until the subclasses have been instantiated.x0a iv. Builder, the construction pattern: separates the construction of a complex object from his representation, making the same building process Separate the construction of a complex object from its representation, allowing the same building process to create different representations.x0a v. Prototype: Specify the kinds of objects to be created with prototype instances, and create new objects by copying these prototypes.x0a Behavioral types are:x0a vi. Iterator: Provide a way to sequentially access the various elements of an aggregated object without exposing the internal representation of that object. need to expose the internal representation of that object. x0a vii. Observer: defines a one-to-many dependency between objects, so that when the state of an object changes, all objects that depend on it are notified of the automatic update. x0a viii. TemplateMethod: defines the skeleton of an algorithm in an operation, while deferring some of the steps to subclasses. x0a ix. TemplateMethod allows subclasses to redefine specific steps of an algorithm without changing the structure of the algorithm.x0a ix. Command: encapsulates a request as an object, allowing you to parameterize clients with different requests, queue up and log requests, and support undoable operations.x0a x. State, State, the state pattern: allows an object to change his behavior when his internal state changes. The object appears to change his class. x0a xi. Strategy, Strategy Pattern: defines a series of algorithms, encapsulates them one by one, and makes them interchangeable; this pattern makes the algorithms independent of the clients that use them. x0a xii. ChinaofResponsibility, Chain-of-Responsibility Pattern: allows multiple objects to have the opportunity to process the request, thus avoiding coupling between the sender and receiver of the request.x0a xiii Mediator pattern: encapsulates a number of object interactions with a single mediator object.x0a xiv Visitor pattern: represents an operation that acts on the elements of an object structure, which allows you to define a new operation that acts on an element without changing the class of the element.x0a xv Visitor pattern: represents a new operation that acts on an element without changing the class of the element.x0a xvi Visitor pattern: represents a new operation that acts on an element without changing the class of the element. x0a xv. Interpreter, Interpreter Pattern: Given a language, define a representation of his grammar and define an interpreter that uses that representation to interpret sentences in the language.x0a xvi. Memento, Memo Pattern: Capture the internal state of an object without destroying the object and save the state outside the object.x0a xvii. This state is preserved outside of the object. x0a Structural types are: x0a xvii, Composite, Combination Pattern: combines objects into a tree structure to represent the relationship of parts of the whole, Composite makes it possible for the user to have consistency in the use of both individual objects and combinations of them. x0a xviii, Facade, Appearance Pattern: provides consistent interfaces to a set of interfaces in a subsystem, fa?ade Provides a high-level interface that makes the subsystem easier to use. x0a xix, Proxy, Proxy mode: provides a proxy for other objects to control access to the object x0a xx, Adapter, Adapter mode: converts a class of interfaces into another interface that the client wants, the Adapter mode makes it possible to work with classes that could not work together due to interface incompatibility. x0a xx, Adapter, Adapter mode: provides a consistent interface for a set of interfaces in a subsystem. Adapter pattern makes it possible to work with classes that would otherwise not work together due to interface incompatibility.x0a xxi. Decorator pattern: dynamically adds some additional responsibilities to an object, in terms of increased functionality, the Decorator pattern is more flexible than generating subclasses.x0a xxii. xxiii. Flyweight, hedonic pattern.
How to categorize design patterns in java
Design Patterns: a pattern is a problem-solving idea that has been applied to a practical environment. And can be applied to other environments.
Categorization of design patterns: distributed programming patterns, user interface patterns, data model patterns three categories.
The role of design patterns: reuse of design;
provide a common vocabulary for design, each pattern name is a design vocabulary, the concept of which makes it easy for programmers to communicate;
using a vocabulary of patterns in your development documentation can make it easier for other people to understand your ideas.
Categorization of GoF Design Patterns:
Categorized according to the purpose criterion:
1. Creational: creational is related to the creation of objects.
2. Structural: Structural deals with the combination between classes or objects.
3. Behavioral: behavioral describes how classes or objects interact and how responsibilities are assigned.
1. Adapter Pattern
2. Bridge Pattern
3. Composite Pattern
4. Decorator Pattern
5. Facade Pattern
6. 6.Hedonic Pattern Flyweight
7.Proxy Pattern Proxy
1.ChainofResponsibility Pattern ChainofResponsibility
2.Command Pattern Command
3.Interpreter Pattern Interpreter
4. p>4. Iterator pattern Iterator
5. Mediator pattern Mediator
6. Memo pattern Memento
7. Observer pattern Observer
8. State pattern State
9. Strategy pattern Strategy
10. TemplateMethod pattern
11. Visitor patternVisitor